Re: cvs: /php3/functions fsock.c
| From: | Thies C. Arntzen | Date: | Tue, 13 Jul 1999 18:07:20 +0000 |
| Subject: | Re: cvs: /php3/functions fsock.c | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-8450@lists.php.net to get a copy of this message | ||
be the force with you sascha!
tc
On Tue, 13 Jul 1999, sas wrote:
> sas Tue Jul 13 12:33:38 1999 EDT
>
> Modified files:
> /php3/functions fsock.c
> Log:
> I convinced myself that this more complex form is necessary
> to avoid staling on blocking sockets, since we don't _need_
> to read maxlen.
>
> This is real-world tested, so everybody should be happy with
> this code now.
>
>
> Index: php3/functions/fsock.c
> diff -u php3/functions/fsock.c:1.130 php3/functions/fsock.c:1.131
> --- php3/functions/fsock.c:1.130 Sat Jul 10 21:28:47 1999
> +++ php3/functions/fsock.c Tue Jul 13 12:33:37 1999
> @@ -27,7 +27,7 @@
> | Jim Winstead (jimw@php.net) |
> +----------------------------------------------------------------------+
> */
> -/* $Id: fsock.c,v 1.130 1999/07/11 01:28:47 sas Exp $ */
> +/* $Id: fsock.c,v 1.131 1999/07/13 16:33:37 sas Exp $ */
> #ifdef THREAD_SAFE
> #include "tls.h"
> #endif
> @@ -594,14 +594,31 @@
> * FIXME: fgets depends on '\n' as line delimiter
> */
>
> +#define SEARCHCR \
> + p = memchr(READPTR(sock), '\n', MIN(TOREAD(sock), maxlen - 1));
> +
> char *_php3_sock_fgets(char *buf, size_t maxlen, int socket)
> {
> char *p = NULL;
> char *ret = NULL;
> size_t amount = 0;
> - SOCK_FIND_AND_READ_MAX(maxlen);
> -
> - p = memchr(READPTR(sock), '\n', MIN(TOREAD(sock), maxlen - 1));
> + size_t nr_read;
> + SOCK_FIND(sock, socket);
> +
> + SEARCHCR;
> +
> + if(!p) {
> + if(sock->is_blocked) {
> + for(nr_read = 0; !p && !sock->eof && nr_read < maxlen; ) {
> + nr_read += _php3_sock_read_internal(sock);
> + SEARCHCR;
> + }
> + } else {
> + _php3_sock_read(sock);
> + SEARCHCR;
> + }
> + }
> +
>
> if(p) {
> amount = (ptrdiff_t) p - (ptrdiff_t) READPTR(sock) + 1;
>
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
> For additional commands, e-mail: php-dev-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!"
Digital Collections Phone +49 40 235350 Fax +49 40 23535180
Hammerbrookstr. 93 20097 Hamburg / Germany