Skip to content

Commit

Permalink
SAPIfication, Episode VI: Return of the SAPI
Browse files Browse the repository at this point in the history
Remove mostly all references to APACHE and CGI_BINARY from the code.

- Apache include files are no longer included by any PHP code, except for the Apache SAPI module.
- No server specific code is in any of the base PHP code.

Still left to be done:
- Eliminate any references to APACHE from the few remaining modules.
- Move request_info.c's logic to SAPI
- Modify the regex function names, and globals, so that we can always
  include them, without having to fear any interference with Apache;
  Always use the bundled regex library
  • Loading branch information
zsuraski committed Feb 10, 2000
1 parent 9709f7e commit 6d0ab61
Show file tree
Hide file tree
Showing 33 changed files with 108 additions and 352 deletions.
3 changes: 0 additions & 3 deletions acconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@
/* Define if you have the sendmail program available */
#define HAVE_SENDMAIL 0

/* Define if you are compiling PHP as an Apache module */
#define APACHE 0

/* Define if you are compiling PHP as an Apache module with mod_charset patch applied (aka Russian Apache)*/
#define USE_TRANSFER_TABLES 0

Expand Down
2 changes: 0 additions & 2 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,6 @@ if test "$REGEX_TYPE" = "php"; then
PHP_FAST_OUTPUT(regex/Makefile)
elif test "$REGEX_TYPE" = "system"; then
AC_DEFINE(REGEX,0)
elif test "$REGEX_TYPE" = "apache"; then
AC_DEFINE(REGEX,2)
fi
AC_MSG_CHECKING(which regex library to use)
Expand Down
5 changes: 0 additions & 5 deletions ext/aspell/aspell.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
#if HAVE_ASPELL

#include "php_aspell.h"
#if APACHE
# ifndef DEBUG
# undef palloc
# endif
#endif
#include <aspell-c.h>

function_entry aspell_functions[] = {
Expand Down
2 changes: 1 addition & 1 deletion ext/db/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ dbm_info *php_dbm_open(char *filename, char *mode) {
#if NFS_HACK
while((last_try = stat(lockfn,&sb))==0) {
retries++;
sleep(1);
php_sleep(1);
if (retries>30) break;
}
if (last_try!=0) {
Expand Down
3 changes: 1 addition & 2 deletions ext/ereg/php_regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
* REGEX means:
* 0.. system regex
* 1.. bundled regex
* 2.. Apache's regex
*/

#if REGEX == 1
#if REGEX
/* get aliases */
#include "regex/regex_extra.h"
#include "regex/regex.h"
Expand Down
4 changes: 2 additions & 2 deletions ext/hyperwave/hg_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ static int hg_read(int sockfd, char *buf, int size)
if ( (errno == EAGAIN) || (errno == EWOULDBLOCK) ) {
if ( ++try > 5 )
return(-1);
sleep(1);
php_sleep(1);
}
else return(-1);
}
Expand All @@ -1159,7 +1159,7 @@ static int hg_write(int sockfd, char *buf, int size)
if ( (errno == EAGAIN) || (errno == EWOULDBLOCK) ) {
if ( ++try > 5 )
return(-1);
sleep(1);
php_sleep(1);
}
else return(-1);
}
Expand Down
38 changes: 0 additions & 38 deletions ext/mysql/php_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ PHP_MYSQL_API php_mysql_globals mysql_globals;
DLEXPORT zend_module_entry *get_module(void) { return &mysql_module_entry; }
#endif

#if APACHE
void timeout(int sig);
#endif

#define CHECK_LINK(link) { if (link==-1) { php_error(E_WARNING,"MySQL: A link to the server could not be established"); RETURN_FALSE; } }

Expand All @@ -187,42 +184,19 @@ static void php_mysql_set_default_link(int id)

static void _close_mysql_link(MYSQL *link)
{
#if APACHE
void (*handler) (int);
#endif
MySLS_FETCH();

#if APACHE
handler = signal(SIGPIPE, SIG_IGN);
#endif

mysql_close(link);

#if APACHE
signal(SIGPIPE,handler);
#endif

efree(link);
MySG(num_links)--;
}

static void _close_mysql_plink(MYSQL *link)
{
#if APACHE
void (*handler) (int);
#endif
MySLS_FETCH();

#if APACHE
handler = signal(SIGPIPE, SIG_IGN);
#endif

mysql_close(link);

#if APACHE
signal(SIGPIPE,handler);
#endif

free(link);
MySG(num_persistent)--;
MySG(num_links)--;
Expand Down Expand Up @@ -338,9 +312,6 @@ PHP_MINFO_FUNCTION(mysql)

static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
{
#if APACHE
void (*handler) (int);
#endif
char *user,*passwd,*host,*socket=NULL,*tmp;
char *hashed_details;
int hashed_details_length,port = MYSQL_PORT;
Expand Down Expand Up @@ -478,18 +449,12 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
RETURN_FALSE;
}
/* ensure that the link did not die */
#if APACHE
handler=signal(SIGPIPE,SIG_IGN);
#endif
#if defined(HAVE_MYSQL_ERRNO) && defined(CR_SERVER_GONE_ERROR)
mysql_stat(le->ptr);
if (mysql_errno((MYSQL *)le->ptr) == CR_SERVER_GONE_ERROR) {
#else
if (!strcasecmp(mysql_stat(le->ptr),"mysql server has gone away")) { /* the link died */
#endif
#if APACHE
signal(SIGPIPE,handler);
#endif
#if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
if (mysql_real_connect(le->ptr,host,user,passwd,NULL,port,socket,0)==NULL) {
#else
Expand All @@ -501,9 +466,6 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
RETURN_FALSE;
}
}
#if APACHE
signal(SIGPIPE,handler);
#endif
mysql = (MYSQL *) le->ptr;
}
ZEND_REGISTER_RESOURCE(return_value, mysql, le_plink);
Expand Down
2 changes: 1 addition & 1 deletion ext/oci8/oci8.c
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ oci_failover_callback(dvoid *svchp,
case OCI_FO_ERROR:
{
printf(" Failover error gotten. Sleeping...\n");
sleep(3);
php_sleep(3);
/* cannot find this blody define !!! return OCI_FO_RETRY; */
break;
}
Expand Down
4 changes: 0 additions & 4 deletions ext/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ zend_module_entry posix_module_entry = {
DLEXPORT zend_module_entry *get_module(void) { return &posix__module_entry; }
#endif

#if APACHE
void timeout(int sig);
#endif

static PHP_MINFO_FUNCTION(posix)
{
PUTS("$Revision$\n");
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ PHP_FUNCTION(sleep)
WRONG_PARAM_COUNT;
}
convert_to_long_ex(num);
sleep((*num)->value.lval);
php_sleep((*num)->value.lval);
}

PHP_FUNCTION(usleep)
Expand Down
1 change: 1 addition & 0 deletions ext/standard/browscap.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include "php.h"
#include "php_regex.h"
#include "php_browscap.h"
#include "php_ini.h"

Expand Down
10 changes: 5 additions & 5 deletions ext/standard/dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void php_dl(pval *file,int type,pval *return_value)
}

/* load dynamic symbol */
handle = dlopen(libpath, RTLD_LAZY);
handle = DL_LOAD(libpath);
if (!handle) {
int error_type;

Expand All @@ -120,10 +120,10 @@ void php_dl(pval *file,int type,pval *return_value)
#endif
RETURN_FALSE;
}
get_module = (zend_module_entry *(*)(void)) dlsym(handle, "get_module");
get_module = (zend_module_entry *(*)(void)) DL_FETCH_SYMBOL(handle, "get_module");

if (!get_module) {
dlclose(handle);
DL_UNLOAD(handle);
php_error(E_CORE_WARNING,"Invalid library (maybe not a PHP library) '%s' ",file->value.str.val);
RETURN_FALSE;
}
Expand All @@ -133,7 +133,7 @@ void php_dl(pval *file,int type,pval *return_value)
if (module_entry->module_startup_func) {
if (module_entry->module_startup_func(type, module_entry->module_number ELS_CC)==FAILURE) {
php_error(E_CORE_WARNING,"%s: Unable to initialize module",module_entry->name);
dlclose(handle);
DL_UNLOAD(handle);
RETURN_FALSE;
}
}
Expand All @@ -143,7 +143,7 @@ void php_dl(pval *file,int type,pval *return_value)
if (module_entry->request_startup_func) {
if (module_entry->request_startup_func(type, module_entry->module_number ELS_CC)) {
php_error(E_CORE_WARNING,"%s: Unable to initialize module",module_entry->name);
dlclose(handle);
DL_UNLOAD(handle);
RETURN_FALSE;
}
}
Expand Down
21 changes: 1 addition & 20 deletions ext/standard/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,27 +145,8 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value)


if (type == 1) {
#if APACHE
SLS_FETCH();
#endif

if (output) PUTS(buf);
#if APACHE
# if MODULE_MAGIC_NUMBER > 19970110
if (output) rflush(((request_rec *) SG(server_context)));
# else
if (output) bflush(((request_rec *) SG(server_context))->connection->client);
# endif
#endif
#if CGI_BINARY
fflush(stdout);
#endif
#if FHTTPD
/* fhttpd doesn't flush */
#endif
#if USE_SAPI
sapi_rqst->flush(sapi_rqst->scid);
#endif
sapi_flush();
}
else if (type == 2) {
/* strip trailing whitespaces */
Expand Down
Loading

0 comments on commit 6d0ab61

Please sign in to comment.