You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Dean Gaudet <dg...@hyperreal.com> on 1997/06/29 21:19:42 UTC

cvs commit: apache/src alloc.c buff.c http_bprintf.c http_log.c http_main.c httpd.h util_script.c

dgaudet     97/06/29 12:19:41

  Modified:    src       alloc.c buff.c http_bprintf.c http_log.c
                        http_main.c httpd.h  util_script.c
  Log:
  Don't redefine assert() since it's frequently, but not always a macro.
  Use ap_assert.  Unix assert does an abort() which causes a core dump which
  is frequently useful.  Use fprintf rather than nesting into log_unixerr.
  
  Revision  Changes    Path
  1.35      +0 -1      apache/src/alloc.c
  
  Index: alloc.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/alloc.c,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -C3 -r1.34 -r1.35
  *** alloc.c	1997/06/28 20:24:27	1.34
  --- alloc.c	1997/06/29 19:19:34	1.35
  ***************
  *** 62,68 ****
    #include "multithread.h"
    
    #include <stdarg.h>
  - #include <assert.h>
    
    /*****************************************************************
     *
  --- 62,67 ----
  
  
  
  1.31      +2 -3      apache/src/buff.c
  
  Index: buff.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/buff.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -C3 -r1.30 -r1.31
  *** buff.c	1997/06/28 22:39:20	1.30
  --- buff.c	1997/06/29 19:19:34	1.31
  ***************
  *** 96,102 ****
     */
    
    #ifdef WIN32
  - #include <assert.h>
    
    int
    sendwithtimeout(int sock, const char *buf, int len, int flags)
  --- 96,101 ----
  ***************
  *** 115,121 ****
        if(rv)
        {
            err = WSAGetLastError();
  !         assert(0);
        }
        rv = send(sock, buf, len, flags);
        if(rv == SOCKET_ERROR)
  --- 114,120 ----
        if(rv)
        {
            err = WSAGetLastError();
  !         ap_assert(0);
        }
        rv = send(sock, buf, len, flags);
        if(rv == SOCKET_ERROR)
  ***************
  *** 160,166 ****
        
        rv = ioctlsocket(sock, FIONBIO, &iostate);
        iostate = 0;
  !     assert(!rv);
        rv = recv(sock, buf, len, flags);
        if(rv == SOCKET_ERROR)
        {
  --- 159,165 ----
        
        rv = ioctlsocket(sock, FIONBIO, &iostate);
        iostate = 0;
  !     ap_assert(!rv);
        rv = recv(sock, buf, len, flags);
        if(rv == SOCKET_ERROR)
        {
  
  
  
  1.9       +3 -6      apache/src/http_bprintf.c
  
  Index: http_bprintf.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/http_bprintf.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -C3 -r1.8 -r1.9
  *** http_bprintf.c	1997/02/16 07:44:14	1.8
  --- http_bprintf.c	1997/06/29 19:19:35	1.9
  ***************
  *** 14,24 ****
     *
     */
    
  ! #include <assert.h>
    #include <math.h>
  - #include "conf.h"
  - #include "alloc.h"
  - #include "buff.h"
    
    #if !defined(max)
    #define max(a,b)	(a > b ? a : b)
  --- 14,21 ----
     *
     */
    
  ! #include "httpd.h"
    #include <math.h>
    
    #if !defined(max)
    #define max(a,b)	(a > b ? a : b)
  ***************
  *** 254,260 ****
    		    }
                    op = *p;
                    CopyAndAdvance(&fmtBuffPtr, &p, 1);
  !                 assert(fmtBuffPtr - fmtBuff < FMT_BUFFLEN);
                    *fmtBuffPtr = '\0';
    		/*
    		bwrite(bp,"[",1);
  --- 251,257 ----
    		    }
                    op = *p;
                    CopyAndAdvance(&fmtBuffPtr, &p, 1);
  !                 ap_assert(fmtBuffPtr - fmtBuff < FMT_BUFFLEN);
                    *fmtBuffPtr = '\0';
    		/*
    		bwrite(bp,"[",1);
  ***************
  *** 578,584 ****
    		goto ErrorReturn;
                fastPath = FALSE;
    	    } /* for (;;) */
  !         assert(buffCount < buffLen);
            if(buffCount > 0)
    	    {
                if(bwrite(bp,buffPtr,buffCount) < 0)
  --- 575,581 ----
    		goto ErrorReturn;
                fastPath = FALSE;
    	    } /* for (;;) */
  !         ap_assert(buffCount < buffLen);
            if(buffCount > 0)
    	    {
                if(bwrite(bp,buffPtr,buffCount) < 0)
  
  
  
  1.18      +7 -5      apache/src/http_log.c
  
  Index: http_log.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/http_log.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -C3 -r1.17 -r1.18
  *** http_log.c	1997/06/29 15:25:21	1.17
  --- http_log.c	1997/06/29 19:19:35	1.18
  ***************
  *** 208,217 ****
    
    void log_assert(const char *szExp,const char *szFile,int nLine)
    {
  !     char buf[1000];
  ! 
  !     ap_snprintf(buf, sizeof(buf), 
  !         "line %d, assertion \"%s\" failed",nLine,szExp);
  !     log_unixerr("assert",szFile,buf,NULL);
        exit(1);
    }
  --- 208,219 ----
    
    void log_assert(const char *szExp,const char *szFile,int nLine)
    {
  !     fprintf(stderr, "[%s] file %s, line %d, assertion \"%s\" failed\n",
  ! 	get_time(), szFile, nLine, szExp);
  ! #ifndef WIN32
  !     /* unix assert does an abort leading to a core dump */
  !     abort();
  ! #else
        exit(1);
  + #endif
    }
  
  
  
  1.169     +21 -22    apache/src/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/http_main.c,v
  retrieving revision 1.168
  retrieving revision 1.169
  diff -C3 -r1.168 -r1.169
  *** http_main.c	1997/06/29 18:25:55	1.168
  --- http_main.c	1997/06/29 19:19:35	1.169
  ***************
  *** 85,91 ****
    #include "http_core.h"          /* for get_remote_host */
    #include "scoreboard.h"
    #include "multithread.h"
  - #include <assert.h>
    #include <sys/stat.h>
    #ifdef HAVE_SHMGET
    #include <sys/types.h>
  --- 85,90 ----
  ***************
  *** 745,757 ****
    
    void reinit_scoreboard (pool *p)
    {
  !     assert(!scoreboard_image);
        scoreboard_image = (scoreboard *)calloc(HARD_SERVER_LIMIT, sizeof(short_score));
    }
    
    void cleanup_scoreboard ()
    {
  !     assert(scoreboard_image);
        free(scoreboard_image);
        scoreboard_image = NULL;
    }
  --- 744,756 ----
    
    void reinit_scoreboard (pool *p)
    {
  !     ap_assert(!scoreboard_image);
        scoreboard_image = (scoreboard *)calloc(HARD_SERVER_LIMIT, sizeof(short_score));
    }
    
    void cleanup_scoreboard ()
    {
  !     ap_assert(scoreboard_image);
        free(scoreboard_image);
        scoreboard_image = NULL;
    }
  ***************
  *** 1892,1898 ****
    {
        listen_rec *lr;
    
  !     assert(old_listeners == NULL);
        for (lr = listeners; lr; lr = lr->next) {
    	listen_rec *nr = malloc(sizeof *nr);
    	if (nr == NULL) {
  --- 1891,1897 ----
    {
        listen_rec *lr;
    
  !     ap_assert(old_listeners == NULL);
        for (lr = listeners; lr; lr = lr->next) {
    	listen_rec *nr = malloc(sizeof *nr);
    	if (nr == NULL) {
  ***************
  *** 1902,1908 ****
    	*nr = *lr;
    	kill_cleanups_for_socket(p, nr->fd);
    	nr->next = old_listeners;
  ! 	assert(!nr->used);
    	old_listeners = nr;
        }
    }
  --- 1901,1907 ----
    	*nr = *lr;
    	kill_cleanups_for_socket(p, nr->fd);
    	nr->next = old_listeners;
  ! 	ap_assert(!nr->used);
    	old_listeners = nr;
        }
    }
  ***************
  *** 2746,2752 ****
    {
        joblist *new_job;
        
  !     assert(allowed_globals.jobmutex);
        /* TODO: If too many jobs in queue, sleep, check for problems */
        acquire_mutex(allowed_globals.jobmutex);
        new_job = (joblist *)malloc(sizeof(joblist));
  --- 2745,2751 ----
    {
        joblist *new_job;
        
  !     ap_assert(allowed_globals.jobmutex);
        /* TODO: If too many jobs in queue, sleep, check for problems */
        acquire_mutex(allowed_globals.jobmutex);
        new_job = (joblist *)malloc(sizeof(joblist));
  ***************
  *** 2768,2774 ****
        joblist *job;
        int sock;
        
  !     assert(allowed_globals.jobmutex);
        acquire_semaphore(allowed_globals.jobsemaphore);
        acquire_mutex(allowed_globals.jobmutex);
        if(allowed_globals.exit_now && !allowed_globals.jobhead)
  --- 2767,2773 ----
        joblist *job;
        int sock;
        
  !     ap_assert(allowed_globals.jobmutex);
        acquire_semaphore(allowed_globals.jobsemaphore);
        acquire_mutex(allowed_globals.jobmutex);
        if(allowed_globals.exit_now && !allowed_globals.jobhead)
  ***************
  *** 2777,2783 ****
            return(-1);
        }
        job = allowed_globals.jobhead;
  !     assert(job);
        allowed_globals.jobhead = job->next;
        if(allowed_globals.jobhead == NULL)
            allowed_globals.jobtail = NULL;
  --- 2776,2782 ----
            return(-1);
        }
        job = allowed_globals.jobhead;
  !     ap_assert(job);
        allowed_globals.jobhead = job->next;
        if(allowed_globals.jobhead == NULL)
            allowed_globals.jobtail = NULL;
  ***************
  *** 3100,3106 ****
    		for (lr=listeners; lr != NULL; lr=lr->next)
    		{
    		/* to prove a point - Ben */
  ! 		    assert(!lr->used);
    		    if(lr->used)
    		    {
    			listen(lr->fd, 1);
  --- 3099,3105 ----
    		for (lr=listeners; lr != NULL; lr=lr->next)
    		{
    		/* to prove a point - Ben */
  ! 		    ap_assert(!lr->used);
    		    if(lr->used)
    		    {
    			listen(lr->fd, 1);
  ***************
  *** 3111,3125 ****
            if(!start_exit)
            {
                rv = WaitForSingleObject(exit_event, 0);
  !             assert((rv == WAIT_TIMEOUT) || (rv == WAIT_OBJECT_0));
                if(rv == WAIT_OBJECT_0)
                    break;
                rv = WaitForMultipleObjects(nthreads, child_handles, 0, 0);
  ! 	    assert(rv != WAIT_FAILED);
                if(rv != WAIT_TIMEOUT)
                {
                    rv = rv - WAIT_OBJECT_0;
  !                 assert((rv >= 0) && (rv < nthreads));
                    cleanup_thread(child_handles, &nthreads, rv);
                    break;
                }
  --- 3110,3124 ----
            if(!start_exit)
            {
                rv = WaitForSingleObject(exit_event, 0);
  !             ap_assert((rv == WAIT_TIMEOUT) || (rv == WAIT_OBJECT_0));
                if(rv == WAIT_OBJECT_0)
                    break;
                rv = WaitForMultipleObjects(nthreads, child_handles, 0, 0);
  ! 	    ap_assert(rv != WAIT_FAILED);
                if(rv != WAIT_TIMEOUT)
                {
                    rv = rv - WAIT_OBJECT_0;
  !                 ap_assert((rv >= 0) && (rv < nthreads));
                    cleanup_thread(child_handles, &nthreads, rv);
                    break;
                }
  ***************
  *** 3214,3220 ****
    	for (lr=listeners; lr != NULL; lr=lr->next)
    	{
    	/* prove the point again */
  ! 	    assert(!lr->used);
    	    if(lr->used)
    	    {
    		closesocket(lr->fd);
  --- 3213,3219 ----
    	for (lr=listeners; lr != NULL; lr=lr->next)
    	{
    	/* prove the point again */
  ! 	    ap_assert(!lr->used);
    	    if(lr->used)
    	    {
    		closesocket(lr->fd);
  ***************
  *** 3236,3242 ****
            if(rv != WAIT_TIMEOUT)
            {
                rv = rv - WAIT_OBJECT_0;
  !             assert((rv >= 0) && (rv < nthreads));
                cleanup_thread(child_handles, &nthreads, rv);
                continue;
            }
  --- 3235,3241 ----
            if(rv != WAIT_TIMEOUT)
            {
                rv = rv - WAIT_OBJECT_0;
  !             ap_assert((rv >= 0) && (rv < nthreads));
                cleanup_thread(child_handles, &nthreads, rv);
                continue;
            }
  ***************
  *** 3268,3274 ****
        sprintf(buf, "%s_%d", prefix, ++(*child_num));
        _flushall();
        *ev = create_event(0, 0, buf);
  !     assert(*ev);
        pass_argv[0] = argv[0];
        pass_argv[1] = "-c";
        pass_argv[2] = buf;
  --- 3267,3273 ----
        sprintf(buf, "%s_%d", prefix, ++(*child_num));
        _flushall();
        *ev = create_event(0, 0, buf);
  !     ap_assert(*ev);
        pass_argv[0] = argv[0];
        pass_argv[1] = "-c";
        pass_argv[2] = buf;
  ***************
  *** 3318,3339 ****
        {
            service_set_status(SERVICE_START_PENDING);
            child[i] = create_event_and_spawn(argc, argv, &ev[i], &child_num, buf);
  !         assert(child[i] >= 0);
        }
        service_set_status(SERVICE_RUNNING);
    
        for(;!service_stop;)
        {
            rv = WaitForMultipleObjects(nchild, (HANDLE *)child, FALSE, 2000);
  !         assert(rv != WAIT_FAILED);
            if(rv == WAIT_TIMEOUT)
                continue;
            cld = rv - WAIT_OBJECT_0;
  !         assert(rv < nchild);
            CloseHandle((HANDLE)child[rv]);
            CloseHandle(ev[rv]);
            child[rv] = create_event_and_spawn(argc, argv, &ev[rv], &child_num, buf);
  !         assert(child[rv]);
        }
    
        /*
  --- 3317,3338 ----
        {
            service_set_status(SERVICE_START_PENDING);
            child[i] = create_event_and_spawn(argc, argv, &ev[i], &child_num, buf);
  !         ap_assert(child[i] >= 0);
        }
        service_set_status(SERVICE_RUNNING);
    
        for(;!service_stop;)
        {
            rv = WaitForMultipleObjects(nchild, (HANDLE *)child, FALSE, 2000);
  !         ap_assert(rv != WAIT_FAILED);
            if(rv == WAIT_TIMEOUT)
                continue;
            cld = rv - WAIT_OBJECT_0;
  !         ap_assert(rv < nchild);
            CloseHandle((HANDLE)child[rv]);
            CloseHandle(ev[rv]);
            child[rv] = create_event_and_spawn(argc, argv, &ev[rv], &child_num, buf);
  !         ap_assert(child[rv]);
        }
    
        /*
  ***************
  *** 3349,3359 ****
        {
            service_set_status(SERVICE_STOP_PENDING);
            rv = WaitForMultipleObjects(nchild, (HANDLE *)child, FALSE, 2000);
  !         assert(rv != WAIT_FAILED);
            if(rv == WAIT_TIMEOUT)
                continue;
            cld = rv - WAIT_OBJECT_0;
  !         assert(rv < nchild);
            CloseHandle((HANDLE)child[rv]);
            CloseHandle(ev[rv]);
            for(i=rv; i<(nchild-1); i++)
  --- 3348,3358 ----
        {
            service_set_status(SERVICE_STOP_PENDING);
            rv = WaitForMultipleObjects(nchild, (HANDLE *)child, FALSE, 2000);
  !         ap_assert(rv != WAIT_FAILED);
            if(rv == WAIT_TIMEOUT)
                continue;
            cld = rv - WAIT_OBJECT_0;
  !         ap_assert(rv < nchild);
            CloseHandle((HANDLE)child[rv]);
            CloseHandle(ev[rv]);
            for(i=rv; i<(nchild-1); i++)
  ***************
  *** 3423,3429 ****
            case 'c':
                exit_event = open_event(optarg);
                cp = strchr(optarg, '_');
  !             assert(cp);
                *cp = 0;
                start_mutex = open_mutex(optarg);
                child = 1;
  --- 3422,3428 ----
            case 'c':
                exit_event = open_event(optarg);
                cp = strchr(optarg, '_');
  !             ap_assert(cp);
                *cp = 0;
                start_mutex = open_mutex(optarg);
                child = 1;
  
  
  
  1.119     +1 -1      apache/src/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /export/home/cvs/apache/src/httpd.h,v
  retrieving revision 1.118
  retrieving revision 1.119
  diff -C3 -r1.118 -r1.119
  *** httpd.h	1997/06/28 23:57:57	1.118
  --- httpd.h	1997/06/29 19:19:36	1.119
  ***************
  *** 767,770 ****
     * Redefine assert() to something more useful for an Apache...
     */
    void log_assert(const char *szExp,const char *szFile,int nLine);
  ! #define assert(exp) (void)( (exp) || (log_assert(#exp, __FILE__, __LINE__), 0) )
  --- 767,770 ----
     * Redefine assert() to something more useful for an Apache...
     */
    void log_assert(const char *szExp,const char *szFile,int nLine);
  ! #define ap_assert(exp) (void)( (exp) || (log_assert(#exp, __FILE__, __LINE__), 0) )
  
  
  
  1.62      +1 -2      apache/src/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/util_script.c,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -C3 -r1.61 -r1.62
  *** util_script.c	1997/06/22 03:40:25	1.61
  --- util_script.c	1997/06/29 19:19:37	1.62
  ***************
  *** 60,66 ****
    #include "http_core.h"		/* For document_root.  Sigh... */
    #include "http_request.h"       /* for sub_req_lookup_uri() */
    #include "util_script.h"
  - #include <assert.h>
    
    /*
     * Various utility functions which are common to a whole lot of
  --- 60,65 ----
  ***************
  *** 661,667 ****
                if (is_exe || is_binary) {
                    pid = spawnve(_P_NOWAIT, r->filename, create_argv(r->pool, argv0, NULL, NULL, r->args, (void *)NULL), env);
                } else if(is_script) {
  ! 	        assert(0);
                    pid = spawnve(_P_NOWAIT, interpreter+2, create_argv(r->pool, interpreter+2, NULL, NULL, r->filename, r->args), env);
                } else {  
                    pid = spawnve(_P_NOWAIT, "CMD.EXE", create_argv_cmd(r->pool, argv0, r->args, r->filename), env);
  --- 660,666 ----
                if (is_exe || is_binary) {
                    pid = spawnve(_P_NOWAIT, r->filename, create_argv(r->pool, argv0, NULL, NULL, r->args, (void *)NULL), env);
                } else if(is_script) {
  ! 	        ap_assert(0);
                    pid = spawnve(_P_NOWAIT, interpreter+2, create_argv(r->pool, interpreter+2, NULL, NULL, r->filename, r->args), env);
                } else {  
                    pid = spawnve(_P_NOWAIT, "CMD.EXE", create_argv_cmd(r->pool, argv0, r->args, r->filename), env);