diff options
author | Robert James Kaes <rjkaes@users.sourceforge.net> | 2001-11-12 21:10:51 +0000 |
---|---|---|
committer | Robert James Kaes <rjkaes@users.sourceforge.net> | 2001-11-12 21:10:51 +0000 |
commit | dde4e9adcc86c8dd2b71c3ef289d6aefd35285f8 (patch) | |
tree | d34b3409357b1d31dec9850bc487903992b3d52b /src/sock.c | |
parent | 99488cbd5e6d1719363a8edc47ca62f1fce82583 (diff) |
Changed the read() call into a recv() call with a flag of NOSIGNAL since I
don't want signals messing up my calling conventions.
Diffstat (limited to 'src/sock.c')
-rw-r--r-- | src/sock.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -1,4 +1,4 @@ -/* $Id: sock.c,v 1.14 2001-10-25 05:10:32 rjkaes Exp $ +/* $Id: sock.c,v 1.15 2001-11-12 21:10:51 rjkaes Exp $ * * Sockets are created and destroyed here. When a new connection comes in from * a client, we need to copy the socket and the create a second socket to the @@ -219,7 +219,7 @@ char *getpeer_string(int fd, char *string) ssize_t safe_write(int fd, const void *buffer, size_t count) { ssize_t len; - + do { len = write(fd, buffer, count); } while (len < 0 && errno == EINTR); @@ -259,18 +259,22 @@ ssize_t readline(int fd, char *ptr, size_t maxlen) for (n = 1; n < maxlen; n++) { again: - if ((rc = read(fd, &c, 1)) == 1) { + if ((rc = recv(fd, &c, 1, MSG_NOSIGNAL)) == 1) { *ptr++ = c; if (c == '\n') break; } else if (rc == 0) { - if (n == 1) + if (n == 1) { + DEBUG2("File_Desc: %d Closed.", fd); return 0; - else + } else break; } else { if (errno == EINTR) goto again; + + DEBUG2("File_Desc: %d \"%s\" (%d)", fd, strerror(errno), errno); + return -1; } } |