Selaa lähdekoodia

fix sockssend

z3APA3A 5 vuotta sitten
vanhempi
sitoutus
e6a4e1d6e7
1 muutettua tiedostoa jossa 5 lisäystä ja 6 poistoa
  1. 5 6
      src/sockgetchar.c

+ 5 - 6
src/sockgetchar.c

@@ -15,15 +15,14 @@ int socksend(SOCKET sock, char * buf, int bufsize, int to){
  fds.fd = sock;
  do {
 	res = so._send(sock, (char *)buf + sent, bufsize - sent, 0);
-	if(res < 0) {
-		if(errno == EAGAIN || errno == EINTR) continue;
-		break;
+	if(res <= 0) {
+		if(errno != EAGAIN && errno != EINTR) break;
 		fds.events = POLLOUT;
+		fds.fd = sock;
 		if(conf.timetoexit) return sent;
 		res = so._poll(&fds, 1, to*1000);
-		if(res < 0 && (errno == EAGAIN || errno == EINTR)) continue;
-		if(res < 1) break;
-		res = 0;
+		if(res < 1 && errno != EAGAIN && errno != EINTR) break;
+		continue;
 	}
 	sent += res;
  } while (sent < bufsize);