From: <enl...@so...> - 2001-01-23 05:47:38
|
Enlightenment CVS committal Author : cpk Project : e17 Module : apps/efsd Dir : e17/apps/efsd/efsd Modified Files: efsd.c efsd_io.c efsd_misc.c libefsd.c Log Message: Moving back to nonblocking I/O in the server. =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- efsd.c 2001/01/20 14:06:37 1.2 +++ efsd.c 2001/01/23 05:47:55 1.3 @@ -38,10 +38,6 @@ #include <errno.h> #include <fam.h> -#ifdef __EMX__ -#include <strings.h> /* eeek... OS/2 has bzero(...) there */ -#endif - #include <efsd.h> #include <efsd_debug.h> #include <efsd_io.h> @@ -322,6 +318,7 @@ { /* A connected client sent something -- handle it. */ bzero(&ecmd, sizeof(EfsdCommand)); + D(("Reading command ...\n")); if ( (num_read = efsd_read_command(clientfd[i], &ecmd)) >= 0) { if (efsd_handle_client_command(&ecmd, i) < 0) @@ -331,7 +328,7 @@ { efsd_close_connection(i); } - + D(("Done.\n")); efsd_cleanup_command(&ecmd); } } @@ -352,6 +349,13 @@ { D(("New connection -- client %i.\n", i)); clientfd[i] = sock_fd; + + if (fcntl(sock_fd, F_SETFL, O_NONBLOCK) < 0) + { + fprintf(stderr, "Can not fcntl client's socket -- exiting.\n"); + exit(-1); + } + break; } } @@ -414,9 +418,7 @@ } } -#ifndef __EMX__ setsid(); -#endif chdir("/"); umask(0); } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_io.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- efsd_io.c 2001/01/19 01:36:35 1.1 +++ efsd_io.c 2001/01/23 05:47:55 1.2 @@ -30,6 +30,7 @@ #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> +#include <sys/time.h> #include <sys/un.h> #include <string.h> #include <unistd.h> @@ -76,8 +77,10 @@ int read_data(int sockfd, void *dest, int size) { - int num_left, num_read; - char *ptr; + struct timeval t0; + struct timeval t1; + int num_left, num_read; + char *ptr; if (sockfd < 0) return (-1); @@ -86,12 +89,30 @@ num_left = size; num_read = 0; + gettimeofday(&t0, NULL); + while (num_left) { + again: + errno = 0; num_read = read(sockfd, ptr, num_left); if (num_read < 0) - return num_read; /* Error occurred -- return error. */ + { + if (errno == EAGAIN) + { + gettimeofday(&t1, NULL); + if (t0.tv_sec < t1.tv_sec && + t0.tv_usec < t1.tv_usec) + return (-1); + else + goto again; + } + else + { + return (-1); /* Error occurred -- return error. */ + } + } else if (num_read == 0) break; /* End of file */ @@ -390,7 +411,7 @@ if (write_int(sockfd, cmd->efsd_file_cmd.options) < 0) return (-1); - + if (write_string(sockfd, cmd->efsd_file_cmd.file) < 0) return (-1); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_misc.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- efsd_misc.c 2001/01/20 14:06:37 1.3 +++ efsd_misc.c 2001/01/23 05:47:55 1.4 @@ -80,7 +80,7 @@ #ifndef __EMX__ if (s[0] == '/') #else - if ( _fnisabs(s) ) + if (_fnisabs(s)) #endif return (1); @@ -94,7 +94,9 @@ int num = 1; char *p, *q, old; char **result; +#ifdef __EMX__ int drive_present = 0; +#endif if (!s || s[0] == '\0') { =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/libefsd.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- libefsd.c 2001/01/20 14:06:37 1.2 +++ libefsd.c 2001/01/23 05:47:55 1.3 @@ -24,6 +24,7 @@ */ #include <stdlib.h> #include <stdio.h> +#include <fcntl.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> @@ -61,7 +62,7 @@ #ifndef __EMX__ if (file[0] == '/') #else - if ( _fnisabs(file) ) + if (_fnisabs(file)) #endif return strdup(file); |