]> granicus.if.org Git - php/commitdiff
Add sapi_get_fd() and implement it for the Apache/thttpd SAPIs.
authorSascha Schumann <sas@php.net>
Tue, 26 Nov 2002 05:15:55 +0000 (05:15 +0000)
committerSascha Schumann <sas@php.net>
Tue, 26 Nov 2002 05:15:55 +0000 (05:15 +0000)
main/SAPI.c
main/SAPI.h
sapi/apache/mod_php4.c
sapi/thttpd/thttpd.c

index fd9b089bc58c7b3820a9cc3216a0fd2e6a2343b4..f77c14ee112531f740c985288f9cb695c574adb9 100644 (file)
@@ -851,6 +851,15 @@ SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC)
        }
 }
 
+SAPI_API int sapi_get_fd(int *fd TSRMLS_DC)
+{
+       if (sapi_module.get_fd) {
+               return sapi_module.get_fd(fd TSRMLS_CC);
+       } else {
+               return -1;
+       }
+}
+
 /*
  * Local variables:
  * tab-width: 4
index f80d19f7d324917c32215e6b9432a580f8f2c12b..d0238516b5f6fe48122e229afb6c2af6b3f4abb1 100644 (file)
@@ -186,6 +186,8 @@ SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_h
 SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len TSRMLS_DC);
 SAPI_API void sapi_activate_headers_only(TSRMLS_D);
 
+SAPI_API int sapi_get_fd(int *fd TSRMLS_DC);
+
 struct _sapi_module_struct {
        char *name;
        char *pretty_name;
@@ -217,12 +219,16 @@ struct _sapi_module_struct {
 
        void (*block_interruptions)(void);
        void (*unblock_interruptions)(void);
+       
 
        void (*default_post_reader)(TSRMLS_D);
        void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC);
        char *executable_location;
 
        int php_ini_ignore;
+       
+       int (*get_fd)(int *fd TSRMLS_DC);
+
 };
 
 
index ce060e3c7561052251e49e58bb6a871cf0f74d88..eac37883a7a1608acb11b7f6913a041b22dd8fd6 100644 (file)
@@ -343,6 +343,23 @@ static char *php_apache_getenv(char *name, size_t name_len TSRMLS_DC)
 }
 /* }}} */
 
+/* {{{ sapi_apache_get_fd
+ */
+static int sapi_apache_get_fd(int *nfd TSRMLS_DC)
+{
+       request_rec *r = SG(server_context);
+       int fd;
+
+       fd = r->connection->client->fd;
+       
+       if (fd >= 0) {
+               if (nfd) *nfd = fd;
+               return 0;
+       }
+       return -1;
+}
+/* }}} */
+
 /* {{{ sapi_module_struct apache_sapi_module
  */
 static sapi_module_struct apache_sapi_module = {
@@ -382,7 +399,11 @@ static sapi_module_struct apache_sapi_module = {
        unblock_alarms,                                 /* Unblock interruptions */
 #endif
 
-       STANDARD_SAPI_MODULE_PROPERTIES
+       NULL,                                                   /* default post reader */
+       NULL,                                                   /* treat data */
+       NULL,                                                   /* exe location */
+       0,                                                              /* ini ignore */
+       sapi_apache_get_fd
 };
 /* }}} */
 
index 4f196973ca18e6a61432ee6e5d05201996f085d7..96ba377aecf92f30d6b3f025bafe1ee919655900 100644 (file)
@@ -382,6 +382,12 @@ static int php_thttpd_startup(sapi_module_struct *sapi_module)
        return SUCCESS;
 }
 
+static int sapi_thttpd_get_fd(int *nfd TSRMLS_DC)
+{
+       if (nfd) *nfd = TG(hc)->conn_fd;
+       return 0;
+}
+
 static sapi_module_struct thttpd_sapi_module = {
        "thttpd",
        "thttpd",
@@ -411,7 +417,11 @@ static sapi_module_struct thttpd_sapi_module = {
        NULL,                                                                   /* Block interruptions */
        NULL,                                                                   /* Unblock interruptions */
 
-       STANDARD_SAPI_MODULE_PROPERTIES
+       NULL,
+       NULL,
+       NULL,
+       0,
+       sapi_thttpd_get_fd
 };
 
 static void thttpd_module_main(int show_source TSRMLS_DC)