CVS update: php3/functions

From: Date: Mon, 22 Mar 1999 21:52:49 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-4723@lists.php.net to get a copy of this message
Date: Monday March 22, 1999 @ 16:52 Author: ssb Update of /repository/php3/functions In directory asf:/u/temp/cvs-serv13031 Modified Files: fsock.c Log Message: reduced the number of system calls in fgets() and fread(), was doing one recv() for every single byte!! Index: php3/functions/fsock.c diff -c php3/functions/fsock.c:1.86 php3/functions/fsock.c:1.87 *** php3/functions/fsock.c:1.86 Sat Mar 13 08:25:38 1999 --- php3/functions/fsock.c Mon Mar 22 16:52:47 1999 *************** *** 27,33 **** | Jim Winstead (jimw@php.net) | +----------------------------------------------------------------------+ */ ! /* $Id: fsock.c,v 1.86 1999/03/13 13:25:38 sas Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif --- 27,33 ---- | Jim Winstead (jimw@php.net) | +----------------------------------------------------------------------+ */ ! /* $Id: fsock.c,v 1.87 1999/03/22 21:52:47 ssb Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif *************** *** 281,299 **** int _php3_sock_fgets(char *buf, int maxlen, int socket) { ! int retval; ! int count=0; ! while (count<maxlen && (retval=recv(socket,buf,1,0))!=SOCK_RECV_ERR && retval!=EWOULDBLOCK && retval!=0) { ! if (*buf=='\n') { ! buf++; ! count++; break; } ! buf++; ! count++; } ! *buf = '\0'; return count; } --- 281,308 ---- int _php3_sock_fgets(char *buf, int maxlen, int socket) { ! int retval, count = 0, toread, i; ! while (count < maxlen) { ! toread = maxlen - count; ! retval = recv(socket, buf, toread, 0); ! if (retval <= 0) { break; } ! for (i = 0; i < retval; i++) { ! if (buf[i] == '\n') { ! if (i + count < maxlen) { ! i++; ! } ! count += i; ! buf += i; ! goto sock_fgets_exit; ! } ! } ! count += retval; ! buf += retval; } ! sock_fgets_exit: *buf = '\0'; return count; } *************** *** 301,314 **** int _php3_sock_fread(char *buf, int maxlen, int socket) { ! int retval; ! int count=0; ! while (count<maxlen && (retval=recv(socket,buf,1,0))!=SOCK_RECV_ERR && retval!=EWOULDBLOCK && retval!=0) { ! buf++; ! count++; } - *buf = '\0'; return count; } --- 310,326 ---- int _php3_sock_fread(char *buf, int maxlen, int socket) { ! int retval, count = 0, toread; ! while (count < maxlen) { ! toread = maxlen - count; ! retval = recv(socket, buf, toread, 0); ! if (retval <= 0) { ! break; ! } ! count += retval; ! buf += retval; } *buf = '\0'; return count; } -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#4723) next »