* custom sockets need to work buffered too...
[citadel.git] / citadel / sysdep.c
index 0420bc6c168a2b8e1937be9304f77eb5388b3542..d75b27773d0080fc40b09a8f7e59f151b0275eda 100644 (file)
@@ -479,10 +479,11 @@ int client_write(const char *buf, int nbytes)
                return 0;
        }
 #endif
+       if (Ctx->client_socket == -1) return -1;
 
        fdflags = fcntl(Ctx->client_socket, F_GETFL);
 
-       while (bytes_written < nbytes) {
+       while ((bytes_written < nbytes) && (Ctx->client_socket != -1)){
                if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
                        FD_ZERO(&wset);
                        FD_SET(Ctx->client_socket, &wset);