CVS update: php3/functions

From: Date: Tue, 08 Jun 1999 15:02:41 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-6722@lists.php.net to get a copy of this message
Date: Tuesday June 8, 1999 @ 11:02 Author: sas Update of /repository/php3/functions In directory php:/tmp/cvs-serv2376/functions Modified Files: file.c fsock.c fsock.h Log Message: - integrate sock close handler - file() and related functions spit out strange error messages (not solved) Index: php3/functions/file.c diff -u php3/functions/file.c:1.214 php3/functions/file.c:1.215 --- php3/functions/file.c:1.214 Fri May 28 10:52:46 1999 +++ php3/functions/file.c Tue Jun 8 11:02:41 1999 @@ -26,7 +26,7 @@ | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.214 1999/05/28 14:52:46 sas Exp $ */ +/* $Id: file.c,v 1.215 1999/06/08 15:02:41 sas Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif @@ -86,8 +86,6 @@ extern int fclose(); #endif -static void _php3_closesocket(int *); - #ifndef THREAD_SAFE static int fgetss_state = 0; int le_fp,le_pp; @@ -419,15 +417,8 @@ } static void _php3_closesocket(int *sock) { - int socketd=*sock; - if (socketd){ - _php3_sock_destroy(socketd); - if(!_php3_is_persistent_sock(socketd)) { -#if HAVE_SHUTDOWN - shutdown(socketd, 0); -#endif - SOCK_FCLOSE(socketd); - } + if(sock) { + SOCK_FCLOSE(*sock); efree(sock); } } @@ -844,7 +835,6 @@ return_value->value.str.len = 1; return_value->type = IS_STRING; } - return; } /* }}} */ @@ -1263,17 +1253,6 @@ size += b ; } } -/* - if (issock) { -#if WIN32|WINNT - closesocket(socketd); -#else - close(socketd); -#endif - } else { - fclose(fp); - } -*/ php3_list_delete(id); RETURN_LONG(size); } Index: php3/functions/fsock.c diff -u php3/functions/fsock.c:1.112 php3/functions/fsock.c:1.113 --- php3/functions/fsock.c:1.112 Tue Jun 1 08:41:09 1999 +++ php3/functions/fsock.c Tue Jun 8 11:02:41 1999 @@ -27,7 +27,7 @@ | Jim Winstead (jimw@php.net) | +----------------------------------------------------------------------+ */ -/* $Id: fsock.c,v 1.112 1999/06/01 12:41:09 fmk Exp $ */ +/* $Id: fsock.c,v 1.113 1999/06/08 15:02:41 sas Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif @@ -431,6 +431,7 @@ if((sock->next = phpsockbuf)) phpsockbuf->prev = sock; sock->persistent = persistent; + sock->is_blocked = 1; phpsockbuf = sock; return sock; @@ -450,6 +451,29 @@ return ret; } +int _php3_sock_close(int socket) +{ + int ret = 0; + php3i_sockbuf *sock; + + sock = _php3_sock_find(socket); + if(sock) { + if(!sock->persistent) { +#if HAVE_SHUTDOWN + shutdown(sock->socket, 0); +#endif +#if WIN32||WINNT + closesocket(sock->socket); +#else + close(sock->socket); +#endif + SOCK_DESTROY(sock); + } + } + + return ret; +} + #define CHUNK_SIZE 2048 #define MAX_CHUNKS_PER_READ 10 @@ -608,10 +632,9 @@ /* {{{ module start/shutdown functions */ /* {{{ _php3_sock_destroy */ -static void _php3_msock_destroy(void *data) +static void _php3_msock_destroy(int *data) { - int *sock = (int *) data; - close(*sock); + close(*data); } /* }}} */ /* {{{ php3_minit_fsock */ @@ -620,7 +643,7 @@ { #ifndef THREAD_SAFE _php3_hash_init(&ht_keys, 0, NULL, NULL, 1); - _php3_hash_init(&ht_socks, 0, NULL, _php3_msock_destroy, 1); + _php3_hash_init(&ht_socks, 0, NULL, (void (*)(void *))_php3_msock_destroy, 1); #endif return SUCCESS; } Index: php3/functions/fsock.h diff -u php3/functions/fsock.h:1.22 php3/functions/fsock.h:1.23 --- php3/functions/fsock.h:1.22 Fri May 28 10:52:46 1999 +++ php3/functions/fsock.h Tue Jun 8 11:02:41 1999 @@ -27,7 +27,7 @@ | Jim Winstead (jimw@php.net) | +----------------------------------------------------------------------+ */ -/* $Id: fsock.h,v 1.22 1999/05/28 14:52:46 sas Exp $ */ +/* $Id: fsock.h,v 1.23 1999/06/08 15:02:41 sas Exp $ */ #ifndef _FSOCK_H #define _FSOCK_H @@ -45,6 +45,7 @@ int _php3_is_persistent_sock(int); int _php3_sock_set_blocking(int socket, int mode); int _php3_sock_destroy(int socket); +int _php3_sock_close(int socket); PHPAPI int connect_nonb(int sockfd, struct sockaddr *addr, int addrlen, struct timeval *timeout);

« previous php.dev (#6722) next »