CVS update: php3/functions
| From: | ssb | Date: | Tue, 23 Mar 1999 02:28:14 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-4730@lists.php.net to get a copy of this message | ||
Date: Monday March 22, 1999 @ 21:28
Author: ssb
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv15288
Modified Files:
fsock.c
Log Message:
fix _php3_sock_fread() so it can continue reading a buffered file
Index: php3/functions/fsock.c
diff -c php3/functions/fsock.c:1.89 php3/functions/fsock.c:1.90
*** php3/functions/fsock.c:1.89 Mon Mar 22 20:50:00 1999
--- php3/functions/fsock.c Mon Mar 22 21:28:13 1999
***************
*** 27,33 ****
| Jim Winstead (jimw@php.net) |
+----------------------------------------------------------------------+
*/
! /* $Id: fsock.c,v 1.89 1999/03/23 01:50:00 ssb Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 27,33 ----
| Jim Winstead (jimw@php.net) |
+----------------------------------------------------------------------+
*/
! /* $Id: fsock.c,v 1.90 1999/03/23 02:28:13 ssb Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 285,291 ****
size_t readbuflen;
size_t readpos;
size_t writepos;
- struct php3i_sockbuf *prev;
struct php3i_sockbuf *next;
};
--- 285,290 ----
***************
*** 360,368 ****
sockbuf->readbuflen = maxlen;
sockbuf->readpos = sockbuf->writepos = 0;
sockbuf->next = phpsockbuf;
- if (phpsockbuf != NULL) {
- phpsockbuf->prev = sockbuf;
- }
phpsockbuf = sockbuf;
} else {
int needlen = sockbuf->writepos + buflen;
--- 359,364 ----
***************
*** 378,394 ****
sock_fgets_exit:
if (sockbuf && remove) {
! if (sockbuf->prev) {
! sockbuf->prev->next = sockbuf->next;
! } else {
! phpsockbuf = sockbuf->next;
! }
! if (sockbuf->next) {
! sockbuf->next->prev = sockbuf->prev;
! }
! if (sockbuf->readbuf != NULL) {
! efree(sockbuf->readbuf);
}
efree(sockbuf);
}
*buf = '\0';
--- 374,388 ----
sock_fgets_exit:
if (sockbuf && remove) {
! struct php3i_sockbuf *prev = phpsockbuf;
!
! while (prev) {
! if (prev->next == sockbuf) {
! prev->next = sockbuf->next;
! }
! prev = prev->next;
}
+ efree(sockbuf->readbuf);
efree(sockbuf);
}
*buf = '\0';
***************
*** 398,414 ****
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;
}
--- 392,425 ----
int _php3_sock_fread(char *buf, int maxlen, int socket)
{
! struct php3i_sockbuf *sockbuf = phpsockbuf;
! int bytesread, toread, count = 0, remove = 0;
!
! while (sockbuf) {
! if (sockbuf->socket == socket) {
! toread = sockbuf->writepos - sockbuf->readpos;
! if (toread > maxlen) {
! toread = maxlen;
! }
! memcpy(buf, sockbuf->readbuf + sockbuf->readpos, toread);
! sockbuf->readpos += toread;
! count += toread;
! buf += toread;
! break;
! }
! sockbuf = sockbuf->next;
! }
!
while (count < maxlen) {
toread = maxlen - count;
! bytesread = recv(socket, buf, toread, 0);
! if (bytesread <= 0) {
break;
}
! count += bytesread;
! buf += bytesread;
}
+
*buf = '\0';
return count;
}
***************
*** 420,425 ****
--- 431,456 ----
static void _php3_sock_destroy(void *data)
{
int *sock = (int *) data;
+
+ #if 0
+ if (phpsockbuf) {
+ struct php3i_sockbuf *buf = phpsockbuf, *prev = NULL;
+
+ while (buf) {
+ if (buf->socket == *sock) {
+ if (prev) {
+ prev->next = buf->next;
+ } else {
+ phpsockbuf = buf->next;
+ }
+ efree(buf->readbuf);
+ efree(buf);
+ }
+ prev = buf;
+ buf = buf->next;
+ }
+ }
+ #endif
close(*sock);
}
--
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