wcsession *WCC = WC;
const char *ptr, *eptr;
long count;
- ssize_t res;
+ ssize_t res = 0;
fd_set wset;
int fdflags;
write(2, ptr, StrLength(WCC->WBuf));
write(2, "\033[30m", 5);
#endif
+ if (WCC->Hdr->http_sock != -1)
+ return -1;
fdflags = fcntl(WC->Hdr->http_sock, F_GETFL);
- while (ptr < eptr) {
+ while ((ptr < eptr) && (WCC->Hdr->http_sock != -1)){
if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
FD_ZERO(&wset);
FD_SET(WCC->Hdr->http_sock, &wset);
}
}
- if ((res = write(WCC->Hdr->http_sock,
+ if ((WCC->Hdr->http_sock == -1) ||
+ (res = write(WCC->Hdr->http_sock,
ptr,
count)) == -1) {
lprintf(2, "client_write: Socket write failed (%s)\n", strerror(errno));
write(2, "\033[30m", 5);
#endif
- while (ptr < eptr) {
+ while ((ptr < eptr) && (WCC->Hdr->http_sock != -1)) {
if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
FD_ZERO(&wset);
FD_SET(WCC->Hdr->http_sock, &wset);
}
}
- if ((res = write(WCC->Hdr->http_sock,
+ if ((WCC->Hdr->http_sock == -1) ||
+ (res = write(WCC->Hdr->http_sock,
ptr,
count)) == -1) {
lprintf(2, "client_write: Socket write failed (%s)\n", strerror(errno));
struct timeval tv, start;
gettimeofday(&start, NULL);
+ if (fd == -1)
+ return -1;
shutdown(fd, 1);
do {
do {