CVS update: php3/functions
| From: | sas | Date: | Fri, 28 May 1999 14:52:48 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-6169@lists.php.net to get a copy of this message | ||
Date: Friday May 28, 1999 @ 10:52
Author: sas
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv10147
Modified Files:
file.c fsock.c fsock.h
Log Message:
destroy socket entries properly
Index: php3/functions/file.c
diff -u php3/functions/file.c:1.213 php3/functions/file.c:1.214
--- php3/functions/file.c:1.213 Wed May 26 09:47:10 1999
+++ php3/functions/file.c Fri May 28 10:52:46 1999
@@ -26,7 +26,7 @@
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.213 1999/05/26 13:47:10 sas Exp $ */
+/* $Id: file.c,v 1.214 1999/05/28 14:52:46 sas Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
@@ -421,6 +421,7 @@
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);
Index: php3/functions/fsock.c
diff -u php3/functions/fsock.c:1.108 php3/functions/fsock.c:1.109
--- php3/functions/fsock.c:1.108 Fri May 28 10:08:27 1999
+++ php3/functions/fsock.c Fri May 28 10:52:46 1999
@@ -27,7 +27,7 @@
| Jim Winstead (jimw@php.net) |
+----------------------------------------------------------------------+
*/
-/* $Id: fsock.c,v 1.108 1999/05/28 14:08:27 sas Exp $ */
+/* $Id: fsock.c,v 1.109 1999/05/28 14:52:46 sas Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
@@ -378,6 +378,11 @@
}
/* }}} */
+#define DESTROY_SOCK(sock) \
+ if(sock->readbuf) pefree(sock->readbuf, sock->persistent); \
+ if(sock == phpsockbuf) \
+ phpsockbuf = sock->next; \
+ pefree(sock, sock->persistent)
static void php_cleanup_sockbuf(int persistent)
{
@@ -386,10 +391,7 @@
for(now = phpsockbuf; now; now = next) {
next = now->next;
if(now->persistent == persistent) {
- if(now->readbuf) pefree(now->readbuf, persistent);
- if(now == phpsockbuf)
- phpsockbuf = next;
- pefree(now, persistent);
+ DESTROY_SOCK(now);
}
}
}
@@ -430,6 +432,20 @@
return sock;
}
+int _php3_sock_destroy(int socket)
+{
+ int ret = 0;
+ php3i_sockbuf *sock;
+
+ sock = _php3_sock_find(socket);
+ if(sock) {
+ ret = 1;
+ DESTROY_SOCK(sock);
+ }
+
+ return ret;
+}
+
#define CHUNK_SIZE 2048
#define MAX_CHUNKS_PER_READ 10
@@ -588,7 +604,7 @@
/* {{{ module start/shutdown functions */
/* {{{ _php3_sock_destroy */
-static void _php3_sock_destroy(void *data)
+static void _php3_msock_destroy(void *data)
{
int *sock = (int *) data;
close(*sock);
@@ -600,7 +616,7 @@
{
#ifndef THREAD_SAFE
_php3_hash_init(&ht_keys, 0, NULL, NULL, 1);
- _php3_hash_init(&ht_socks, 0, NULL, _php3_sock_destroy, 1);
+ _php3_hash_init(&ht_socks, 0, NULL, _php3_msock_destroy, 1);
#endif
return SUCCESS;
}
Index: php3/functions/fsock.h
diff -u php3/functions/fsock.h:1.21 php3/functions/fsock.h:1.22
--- php3/functions/fsock.h:1.21 Thu May 27 09:54:26 1999
+++ php3/functions/fsock.h Fri May 28 10:52:46 1999
@@ -27,7 +27,7 @@
| Jim Winstead (jimw@php.net) |
+----------------------------------------------------------------------+
*/
-/* $Id: fsock.h,v 1.21 1999/05/27 13:54:26 sas Exp $ */
+/* $Id: fsock.h,v 1.22 1999/05/28 14:52:46 sas Exp $ */
#ifndef _FSOCK_H
#define _FSOCK_H
@@ -44,6 +44,7 @@
int _php3_sock_fgetc(int socket);
int _php3_is_persistent_sock(int);
int _php3_sock_set_blocking(int socket, int mode);
+int _php3_sock_destroy(int socket);
PHPAPI int connect_nonb(int sockfd, struct sockaddr *addr, int addrlen, struct timeval *timeout);
--
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