Date: 04/29/98
- Next message: zeev: "[PHP-DEV] CVS update: php3"
- Previous message: Zeev Suraski: "Re: [PHP-DEV] Bug #331: static variables in object methods broken"
- Next in thread: Rasmus Lerdorf: "Re: [PHP-DEV] CVS update: php3/functions"
- Reply: Rasmus Lerdorf: "Re: [PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wednesday April 29, 1998 @ 21:48
Author: zeev
Update of /repository/php3/functions
In directory asf:/tmp/cvs-serv20752/functions
Modified Files:
file.c file.h
Log Message:
* Removed a lot of redundant code from set_socket_blocking() (renamed it to set_socket_blocking)
If this code was taken as-is from somewhere else (which I guess it was) - there's a lot of
optimization that can be done.
* Added untested version of set_socket_timeout(). Looks like it'll only be supported in
Linux 2.1 and Solaris.
Index: php3/functions/file.c
diff -c php3/functions/file.c:1.160 php3/functions/file.c:1.161
*** php3/functions/file.c:1.160 Wed Apr 29 10:24:29 1998
--- php3/functions/file.c Wed Apr 29 21:48:05 1998
***************
*** 26,32 ****
| Authors: Rasmus Lerdorf <rasmus <email protected>> |
+----------------------------------------------------------------------+
*/
! /* $Id: file.c,v 1.160 1998/04/29 14:24:29 zeev Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 26,32 ----
| Authors: Rasmus Lerdorf <rasmus <email protected>> |
+----------------------------------------------------------------------+
*/
! /* $Id: file.c,v 1.161 1998/04/30 01:48:05 zeev Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 61,66 ****
--- 61,69 ----
#include <pwd.h>
#endif
#endif
+ #if HAVE_SYS_TIME_H
+ #include <sys/time.h>
+ #endif
#include "snprintf.h"
#include "fsock.h"
#include "fopen-wrappers.h"
***************
*** 100,106 ****
{"copy", php3_file_copy, NULL},
{"tempnam", php3_tempnam, NULL},
{"file", php3_file, NULL},
! {"set_blocking", php3_setblock, NULL},
{NULL, NULL, NULL}
};
--- 103,112 ----
{"copy", php3_file_copy, NULL},
{"tempnam", php3_tempnam, NULL},
{"file", php3_file, NULL},
! {"set_socket_blocking", php3_set_socket_blocking, NULL},
! #if (HAVE_SYS_TIME_H && HAVE_SETSOCKOPT && defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO))
! {"set_socket_timeout", php3_set_socket_timeout, NULL},
! #endif
{NULL, NULL, NULL}
};
***************
*** 398,408 ****
}
}
! void php3_setblock(INTERNAL_FUNCTION_PARAMETERS) {
YYSTYPE *arg1, *arg2;
- FILE *fp;
int id, type, block;
! int issock=0, flags;
int socketd=0, *sock;
TLS_VARS;
--- 404,414 ----
}
}
! void php3_set_socket_blocking(INTERNAL_FUNCTION_PARAMETERS)
! {
YYSTYPE *arg1, *arg2;
int id, type, block;
! int flags;
int socketd=0, *sock;
TLS_VARS;
***************
*** 412,454 ****
convert_to_long(arg1);
convert_to_long(arg2);
id = arg1->value.lval;
- fp = php3_list_find(id,&type);
block = arg2->value.lval;
! if(type==GLOBAL(wsa_fp)){
! issock=1;
! sock = php3_list_find(id,&type);
! socketd=*sock;
! }
! if((!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(le_pp))) && (!socketd || type!=GLOBAL(wsa_fp))) {
! php3_error(E_WARNING,"Unable to find file identifier %d",id);
! RETURN_TRUE;
}
#if WIN32|WINNT
/* need to use ioctl+FIONBIO to do this on Windows */
RETURN_FALSE;
#else
! if(issock) {
! flags = fcntl(socketd, F_GETFL);
! #ifdef O_NONBLOCK
! /* POSIX version */
! if(block) {
! if((flags & O_NONBLOCK)) flags ^= O_NONBLOCK;
! } else {
! if(!(flags & O_NONBLOCK)) flags |= O_NONBLOCK;
}
! #else
! #ifdef O_NDELAY
! /* old non-POSIX version */
! if(block) flags |= O_NDELAY;
! else flags ^= O_NDELAY;
! #endif
! #endif
! fcntl(socketd,F_SETFL,flags);
}
#endif
}
! void php3_fgets(INTERNAL_FUNCTION_PARAMETERS) {
YYSTYPE *arg1, *arg2;
FILE *fp;
int id, len, type;
--- 418,491 ----
convert_to_long(arg1);
convert_to_long(arg2);
id = arg1->value.lval;
block = arg2->value.lval;
!
! sock = php3_list_find(id,&type);
! if (type!=GLOBAL(wsa_fp)) {
! php3_error(E_WARNING,"%d is not a socket id",id);
! RETURN_FALSE;
}
+ socketd=*sock;
#if WIN32|WINNT
/* need to use ioctl+FIONBIO to do this on Windows */
RETURN_FALSE;
#else
! flags = fcntl(socketd, F_GETFL);
! # ifdef O_NONBLOCK
! /* POSIX version */
! if (block) {
! if ((flags & O_NONBLOCK)) {
! flags ^= O_NONBLOCK;
}
! } else {
! if (!(flags & O_NONBLOCK)) {
! flags |= O_NONBLOCK;
! }
! }
! # else
! # ifdef O_NDELAY
! /* old non-POSIX version */
! if (block) {
! flags |= O_NDELAY;
! } else {
! flags ^= O_NDELAY;
}
+ # endif
+ # endif
+ fcntl(socketd,F_SETFL,flags);
#endif
}
!
! #if (HAVE_SYS_TIME_H && HAVE_SETSOCKOPT && defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO))
! void php3_set_socket_timeout(INTERNAL_FUNCTION_PARAMETERS)
! {
! YYSTYPE *socket,*timeout;
! int type, *sock;
! struct timeval t;
!
! if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &socket, &timeout)==FAILURE) {
! WRONG_PARAM_COUNT;
! }
! convert_to_long(socket);
! convert_to_long(timeout);
!
! sock = php3_list_find(socket->value.lval, &type);
! if (type!=GLOBAL(wsa_fp)) {
! php3_error(E_WARNING,"%d is not a socket id",socket->value.lval);
! RETURN_FALSE;
! }
! t.tv_sec = timeout->value.lval;
! t.tv_usec = 0;
! setsockopt(*sock,SOL_SOCKET,SO_SNDTIMEO,&t,sizeof(struct timeval));
! setsockopt(*sock,SOL_SOCKET,SO_RCVTIMEO,&t,sizeof(struct timeval));
! RETURN_TRUE;
! }
! #endif
!
!
! void php3_fgets(INTERNAL_FUNCTION_PARAMETERS)
! {
YYSTYPE *arg1, *arg2;
FILE *fp;
int id, len, type;
Index: php3/functions/file.h
diff -c php3/functions/file.h:1.19 php3/functions/file.h:1.20
*** php3/functions/file.h:1.19 Wed Apr 29 09:24:11 1998
--- php3/functions/file.h Wed Apr 29 21:48:06 1998
***************
*** 27,33 ****
+----------------------------------------------------------------------+
*/
! /* $Id: file.h,v 1.19 1998/04/29 13:24:11 ssb Exp $ */
#ifndef _FILE_H
#define _FILE_H
--- 27,33 ----
+----------------------------------------------------------------------+
*/
! /* $Id: file.h,v 1.20 1998/04/30 01:48:06 zeev Exp $ */
#ifndef _FILE_H
#define _FILE_H
***************
*** 61,66 ****
extern void php3_rename(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_file_copy(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_file(INTERNAL_FUNCTION_PARAMETERS);
! extern void php3_setblock(INTERNAL_FUNCTION_PARAMETERS);
#endif /* _FILE_H */
--- 61,67 ----
extern void php3_rename(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_file_copy(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_file(INTERNAL_FUNCTION_PARAMETERS);
! extern void php3_set_socket_blocking(INTERNAL_FUNCTION_PARAMETERS);
! extern void php3_set_socket_timeout(INTERNAL_FUNCTION_PARAMETERS);
#endif /* _FILE_H */
- Next message: zeev: "[PHP-DEV] CVS update: php3"
- Previous message: Zeev Suraski: "Re: [PHP-DEV] Bug #331: static variables in object methods broken"
- Next in thread: Rasmus Lerdorf: "Re: [PHP-DEV] CVS update: php3/functions"
- Reply: Rasmus Lerdorf: "Re: [PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

