cvs: /php4 main.c mod_php4.c php.h php_globals.h /php4/serverapi cgi_sapi.c isapi_sapi.c nsapi_sapi.c sapi.h
| From: | Rasmus Lerdorf | Date: | Sat, 04 Sep 1999 20:12:48 +0000 |
| Subject: | cvs: /php4 main.c mod_php4.c php.h php_globals.h /php4/serverapi cgi_sapi.c isapi_sapi.c nsapi_sapi.c sapi.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-4090@lists.php.net to get a copy of this message | ||
rasmus Sat Sep 4 16:12:48 1999 EDT
Modified files:
/php4 main.c mod_php4.c php.h php_globals.h
/php4/serverapi cgi_sapi.c isapi_sapi.c nsapi_sapi.c sapi.h
Log:
First part of the connection_status work. No user-callable functions
yet. That is coming next. Have also only done Apache and CGI so far.
Will have to crack open my ISAPI book to do that one.
Also changed the SAPI output functions to return an int. We'll check
the connection status inside each one, but we might need the return
code at some other level and I don't see a good reason for just tossing
these return codes.
Index: php4/main.c
diff -u php4/main.c:1.108 php4/main.c:1.109
--- php4/main.c:1.108 Fri Sep 3 13:46:39 1999
+++ php4/main.c Sat Sep 4 16:12:47 1999
@@ -19,7 +19,7 @@
*/
-/* $Id: main.c,v 1.108 1999/09/03 17:46:39 sas Exp $ */
+/* $Id: main.c,v 1.109 1999/09/04 20:12:47 rasmus Exp $ */
#include <stdio.h>
@@ -228,6 +228,7 @@
STD_PHP_INI_BOOLEAN("track_vars", (PHP_TRACK_VARS?"1":"0"), PHP_INI_ALL, OnUpdateInt, track_vars, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("gpc_order", "GPC", PHP_INI_ALL, OnUpdateStringUnempty, gpc_order, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("arg_separator", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("ignore_user_abort", "1", PHP_INI_ALL, OnUpdateInt, ignore_user_abort, php_core_globals, core_globals)
PHP_INI_END()
@@ -235,14 +236,16 @@
/* True global (no need for thread safety */
static int module_initialized = 0;
-
+#if 0
#if APACHE
void php3_apache_puts(const char *s)
{
SLS_FETCH();
if (SG(server_context)) {
- rputs(s, (request_rec *) SG(server_context));
+ if(rputs(s, (request_rec *) SG(server_context))==-1) {
+ PG(connection_status) = PHP_CONNECTION_ABORTED;
+ }
} else {
fputs(s, stdout);
}
@@ -253,12 +256,15 @@
SLS_FETCH();
if (SG(server_context)) {
- rputc(c, (request_rec *) SG(server_context));
+ if(rputc(c, (request_rec *) SG(server_context))!=c) {
+ PG(connection_status) = PHP_CONNECTION_ABORTED;
+ }
} else {
fputc(c, stdout);
}
}
#endif
+#endif
void php3_log_err(char *log_message)
{
@@ -847,6 +853,7 @@
PG(header_is_being_sent) = 0;
SG(request_info).headers_only = 0;
+ PG(connection_status) = PHP_CONNECTION_NORMAL;
#if HAVE_SETLOCALE
setlocale(LC_CTYPE, "");
Index: php4/mod_php4.c
diff -u php4/mod_php4.c:1.18 php4/mod_php4.c:1.19
--- php4/mod_php4.c:1.18 Sat Aug 28 19:30:37 1999
+++ php4/mod_php4.c Sat Sep 4 16:12:47 1999
@@ -17,7 +17,7 @@
| PHP 4.0 patches by Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: mod_php4.c,v 1.18 1999/08/28 23:30:37 rasmus Exp $ */
+/* $Id: mod_php4.c,v 1.19 1999/09/04 20:12:47 rasmus Exp $ */
#include "httpd.h"
#include "http_config.h"
@@ -94,12 +94,17 @@
static int zend_apache_ub_write(const char *str, uint str_length)
{
SLS_FETCH();
-
+ int ret;
+
if (SG(server_context)) {
- return rwrite(str, str_length, (request_rec *) SG(server_context));
+ ret = rwrite(str, str_length, (request_rec *) SG(server_context));
} else {
- return fwrite(str, 1, str_length, stdout);
+ ret = fwrite(str, 1, str_length, stdout);
+ }
+ if(ret != str_length) {
+ PG(connection_status) = PHP_CONNECTION_ABORTED;
}
+ return ret;
}
@@ -466,7 +471,7 @@
return send_parsed_php(r);
}
-static void apache_php_module_shutdown_wrapper()
+static void apache_php_module_shutdown_wrapper(void)
{
apache_php_initialized = 0;
sapi_module.shutdown(&sapi_module);
Index: php4/php.h
diff -u php4/php.h:1.27 php4/php.h:1.28
--- php4/php.h:1.27 Fri Sep 3 14:32:34 1999
+++ php4/php.h Sat Sep 4 16:12:47 1999
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php.h,v 1.27 1999/09/03 18:32:34 sas Exp $ */
+/* $Id: php.h,v 1.28 1999/09/04 20:12:47 rasmus Exp $ */
#ifndef _PHP_H
#define _PHP_H
@@ -324,6 +324,10 @@
#include "zend_variables.h"
#include "zend_constants.h"
+/* connection status states */
+#define PHP_CONNECTION_NORMAL 0
+#define PHP_CONNECTION_ABORTED 1
+#define PHP_CONNECTION_TIMEOUT 2
/* Finding offsets of elements within structures.
Index: php4/php_globals.h
diff -u php4/php_globals.h:1.19 php4/php_globals.h:1.20
--- php4/php_globals.h:1.19 Tue Aug 24 19:12:50 1999
+++ php4/php_globals.h Sat Sep 4 16:12:47 1999
@@ -83,6 +83,9 @@
long y2k_compliance;
+ short connection_status;
+ short ignore_user_abort;
+
unsigned char header_is_being_sent;
/* for fsock */
Index: php4/serverapi/cgi_sapi.c
diff -u php4/serverapi/cgi_sapi.c:1.4 php4/serverapi/cgi_sapi.c:1.5
--- php4/serverapi/cgi_sapi.c:1.4 Mon Aug 2 15:16:54 1999
+++ php4/serverapi/cgi_sapi.c Sat Sep 4 16:12:47 1999
@@ -25,24 +25,44 @@
return getenv(string);
}
-void sapi_header(void *scid, char *header){
- puts(header);
+int sapi_header(void *scid, char *header){
+ int ret = puts(header);
+ if(ret==EOF) {
+ PG(connection_status) = PHP_CONNECTION_ABORTED;
+ }
+ return ret;
}
-void sapi_flush(void *scid){
- fflush(stdout);
+int sapi_flush(void *scid){
+ int ret = fflush(stdout);
+ if(ret==EOF) {
+ PG(connection_status) = PHP_CONNECTION_ABORTED;
+ }
+ return ret;
}
-void sapi_puts(void *scid, char *string){
- puts(string);
+int sapi_puts(void *scid, char *string){
+ int ret = puts(string);
+ if(ret==EOF) {
+ PG(connection_status) = PHP_CONNECTION_ABORTED;
+ }
+ return ret;
}
-void sapi_putc(void *scid, char c){
- putc(c,stdout);
+int sapi_putc(void *scid, char c){
+ int ret = putc(c,stdout);
+ if(ret!=c) {
+ PG(connection_status) = PHP_CONNECTION_ABORTED;
+ }
+ return ret;
}
int sapi_writeclient(void *scid, char *string, int len){
- return fwrite(string,len,1,stdout);
+ int ret = fwrite(string,len,1,stdout);
+ if(ret!=len) {
+ PG(connection_status) = PHP_CONNECTION_ABORTED;
+ }
+ return ret;
}
void sapi_log(void *scid, char *message){
Index: php4/serverapi/isapi_sapi.c
diff -u php4/serverapi/isapi_sapi.c:1.3 php4/serverapi/isapi_sapi.c:1.4
--- php4/serverapi/isapi_sapi.c:1.3 Mon Aug 2 15:16:54 1999
+++ php4/serverapi/isapi_sapi.c Sat Sep 4 16:12:47 1999
@@ -47,38 +47,44 @@
return estrdup(var);
}
-void sapi_header(void *scid, char *header){
+int sapi_header(void *scid, char *header){
LPEXTENSION_CONTROL_BLOCK lpEcb=scid;
int len=strlen(header);
if (!lpEcb->ServerSupportFunction(lpEcb->ConnID,
HSE_REQ_SEND_URL_REDIRECT_RESP,
- NULL,&len,(LPDWORD)header))
+ NULL,&len,(LPDWORD)header)) {
OutputDebugString("Header Failed\n");
-
+ return -1;
+ }
+ return 1;
}
/*FIXME*/
-void sapi_flush(void *scid){
+int sapi_flush(void *scid){
LPEXTENSION_CONTROL_BLOCK lpEcb=scid;
/*fflush(stdout);*/
+ return 1;
}
-void sapi_puts(void *scid, char *string){
+int sapi_puts(void *scid, char *string){
LPEXTENSION_CONTROL_BLOCK lpEcb=scid;
int n;
n = strlen(string);
- if (!lpEcb->WriteClient(lpEcb->ConnID,string,&n,0))
+ if (!lpEcb->WriteClient(lpEcb->ConnID,string,&n,0)) {
OutputDebugString("PUTS Failed\n");
- return;
+ return -1;
+ }
+ return 1;
}
-void sapi_putc(void *scid, char c){
+int sapi_putc(void *scid, char c){
LPEXTENSION_CONTROL_BLOCK lpEcb=scid;
int n = 1;
if (!lpEcb->WriteClient(lpEcb->ConnID,&c,&n,0)){
OutputDebugString("PUTC Failed\n");
+ return -1;
}
- return;
+ return 1;
}
int sapi_writeclient(void *scid, char *string, int len){
Index: php4/serverapi/nsapi_sapi.c
diff -u php4/serverapi/nsapi_sapi.c:1.2 php4/serverapi/nsapi_sapi.c:1.3
--- php4/serverapi/nsapi_sapi.c:1.2 Wed Apr 21 20:26:01 1999
+++ php4/serverapi/nsapi_sapi.c Sat Sep 4 16:12:47 1999
@@ -83,7 +83,7 @@
}
/* FIXME */
-void sapi_header(void *scid, char *header){
+int sapi_header(void *scid, char *header){
struct ns_request_info *ns_rqst=(struct ns_request_info *)scid;
pblock_remove("content-type",nsrq->srvhdrs);
pblock_nvinsert("content-type","text/html",nsrq->srvhdrs);
@@ -92,18 +92,19 @@
return REQ_PROCEED;
}
-void sapi_flush(void *scid){
+int sapi_flush(void *scid){
struct ns_request_info *ns_rqst=(struct ns_request_info *)scid;
+ return 1;
}
-void sapi_puts(void *scid, char *string){
+int sapi_puts(void *scid, char *string){
struct ns_request_info *ns_rqst=(struct ns_request_info *)scid;
- puts(string);
+ return puts(string);
}
-void sapi_putc(void *scid, char c){
+int sapi_putc(void *scid, char c){
struct ns_request_info *ns_rqst=(struct ns_request_info *)scid;
- net_write(ns_rqst->sn->csd, &c, 1);
+ return net_write(ns_rqst->sn->csd, &c, 1);
}
int sapi_writeclient(void *scid, char *string, int len){
Index: php4/serverapi/sapi.h
diff -u php4/serverapi/sapi.h:1.2 php4/serverapi/sapi.h:1.3
--- php4/serverapi/sapi.h:1.2 Fri Apr 23 20:11:59 1999
+++ php4/serverapi/sapi.h Sat Sep 4 16:12:47 1999
@@ -55,10 +55,10 @@
#endif
/*emulates puts*/
-extern void sapi_puts(void * scid, char *);
+extern int sapi_puts(void * scid, char *);
/*emulates putc*/
-extern void sapi_putc(void * scid, char);
+extern int sapi_putc(void * scid, char);
/*emulates getenv*/
extern char *sapi_getenv(void * scid, char *);
@@ -67,10 +67,10 @@
extern int sapi_writeclient(void * scid, char *, int);
/*flushes any writes to the client*/
-extern void sapi_flush(void * scid);
+extern int sapi_flush(void * scid);
/*sends a header to the client, adds \n\r to the end*/
-extern void sapi_header(void * scid, char *header);
+extern int sapi_header(void * scid, char *header);
/*reads info from the client, used to get post*/
extern int sapi_readclient(void * scid, char *buf, int size, int len);
@@ -89,4 +89,4 @@
extern void sapi_print_info(void *);
-#endif
\ No newline at end of file
+#endif