diff options
author | Andrew Tridgell <tridge@samba.org> | 2002-07-15 10:35:28 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2002-07-15 10:35:28 +0000 |
commit | e90b65284812aaa5ff9e9935ce9bbad7791cbbcd (patch) | |
tree | 9e744d1dc2f93934a4b49166a37383d3cb2b2139 /source3/wrepld/server.c | |
parent | ec167dc9cc0ec2ee461837c25a371d2981744208 (diff) | |
download | samba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.tar.gz samba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.tar.bz2 samba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.zip |
updated the 3.0 branch from the head branch - ready for alpha18
(This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce)
Diffstat (limited to 'source3/wrepld/server.c')
-rw-r--r-- | source3/wrepld/server.c | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/source3/wrepld/server.c b/source3/wrepld/server.c index d078a833ae..740003035c 100644 --- a/source3/wrepld/server.c +++ b/source3/wrepld/server.c @@ -263,7 +263,7 @@ static BOOL create_listen_fdset(void) set_socket_options(s,user_socket_options); if (listen(s, 5) == -1) { - DEBUG(0,("listen: %s\n",strerror(errno))); + DEBUG(5,("listen: %s\n",strerror(errno))); close(s); return False; } @@ -304,17 +304,49 @@ static struct wins_packet_struct *read_wins_packet(int fd, int timeout) { struct wins_packet_struct *p; GENERIC_PACKET *q; - char buf[4096]; + struct BUFFER inbuf; + ssize_t len=0; + size_t total=0; + ssize_t ret; + BOOL ok = False; - if (!receive_smb(fd, buf, timeout)) + inbuf.buffer=NULL; + inbuf.length=0; + inbuf.offset=0; + + if(!grow_buffer(&inbuf, 4)) + return NULL; + + ok = (read(fd, inbuf.buffer,4) == 4); + if (!ok) return NULL; + len = smb_len(inbuf.buffer); + + if (len<=0) + return NULL; + + if(!grow_buffer(&inbuf, len)) + return NULL; + + while (total < len) { + ret = read(fd, inbuf.buffer + total + 4, len - total); + if (ret == 0) { + DEBUG(10,("read_socket_data: recv of %d returned 0. Error = %s\n", (int)(len - total), strerror(errno) )); + return NULL; + } + if (ret == -1) { + DEBUG(0,("read_socket_data: recv failure for %d. Error = %s\n", (int)(len - total), strerror(errno) )); + return NULL; + } + total += ret; + } q = (GENERIC_PACKET *)talloc(mem_ctx, sizeof(GENERIC_PACKET)); p = (struct wins_packet_struct *)talloc(mem_ctx, sizeof(*p)); if (q==NULL || p==NULL) return NULL; - decode_generic_packet(buf, q); + decode_generic_packet(&inbuf, q); q->fd=fd; @@ -403,7 +435,10 @@ static BOOL listen_for_wins_packets(void) /* accept and add the new socket to the listen set */ new_s=accept(s, &addr, &in_addrlen); - + + if (new_s < 0) + continue; + DEBUG(5,("listen_for_wins_packets: new connection, old: %d, new : %d\n", s, new_s)); set_socket_options(new_s, "SO_KEEPALIVE"); |