open-iscsi / target-isns

Target-isns is an iSNS client for the Linux LIO iSCSI target
GNU General Public License v2.0
16 stars 19 forks source link

iSNS registration is lost when running as a daemon #8

Closed cvubrugier closed 10 years ago

cvubrugier commented 10 years ago

The iSNS registration is refreshed every 5 minutes. However, when target-isns is run as a daemon, the first refresh does not work. It seems we are messing with file descriptors. Here the output of strace when target-isns is run as a daemon:

epoll_wait(3, {{EPOLLIN, {u32=5, u64=5}}}, 1, 4294967295) = 1
read(5, "\1\0\0\0\0\0\0\0", 8)          = 8
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 0
connect(0, {sa_family=AF_INET, sin_port=htons(3205), sin_addr=inet_addr("192.168.1.54")}, 128) = 0
sendto(0, "<30>May 25 11:49:41 target-isns:"..., 55, MSG_NOSIGNAL, NULL, 0) = 55
write(0, "\0\1\0\2\0h\214\0\0\5\0\0\0\0\0 \0\0\0<iqn.2003-01."..., 116) = 116pp

The call to sendto() should go to syslog, not on the iSNS socket. In the code, 0 is used as a magic value that means no file descriptor, but that is wrong because 0 is a valid file descriptor.