You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-commits@quetz.apache.org by gr...@apache.org on 2003/07/17 02:51:47 UTC

cvs commit: httpd-python/src/include mod_python.h tableobject.h

grisha      2003/07/16 17:51:47

  Modified:    Doc      modpython4.tex
               src      Makefile.in connobject.c mod_python.c
               src/include mod_python.h tableobject.h
  Log:
  conn.read(len) not returns at most len bytes
  
  Revision  Changes    Path
  1.38      +11 -5     httpd-python/Doc/modpython4.tex
  
  Index: modpython4.tex
  ===================================================================
  RCS file: /home/cvs/httpd-python/Doc/modpython4.tex,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- modpython4.tex	11 Jul 2003 01:37:39 -0000	1.37
  +++ modpython4.tex	17 Jul 2003 00:51:46 -0000	1.38
  @@ -996,13 +996,19 @@
   
   \subsubsection{Connection Methods\label{pyapi-mpconn-meth}}
   
  -\begin{methoddesc}[connection]{read}{length}
  -  Reads \var{length} bytes from the connection. The read blocks
  -  indefinitely until length bytes has been read. If length is -1, keep
  -  reading until the socket is closed from the other end (This is known
  -  as \code{EXHAUSTIVE} mode in the http server code).
  +\begin{methoddesc}[connection]{read}{\optional{length}}
  +  Reads at most \var{length} bytes from the client. The read blocks
  +  indefinitely until there is at least one byte to read. If length is
  +  -1, keep reading until the socket is closed from the other end (This
  +  is known as \code{EXHAUSTIVE} mode in the http server code).
   
     This method should only be used inside \emph{Connection Handlers}.
  +
  +  \begin{notice}
  +    The behaviour of this method has changed since version 3.0.3. In
  +    3.0.3 and prior, this method would block until \var{length} bytes
  +    was read.
  +  \end{notice}
   
   \end{methoddesc}
   
  
  
  
  1.34      +1 -1      httpd-python/src/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/httpd-python/src/Makefile.in,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- Makefile.in	30 May 2003 15:10:46 -0000	1.33
  +++ Makefile.in	17 Jul 2003 00:51:46 -0000	1.34
  @@ -95,7 +95,7 @@
   	@echo
   
   clean:
  -	rm -rf $(OBJS) core libpython.a mod_python.so *~ .libs *.o *.slo *.lo *.la psp_parser.c
  +	rm -rf $(OBJS) core libpython.a mod_python.so *~ .libs *.o *.slo *.lo *.la 
   
   distclean: clean
   	rm -f Makefile .depend .install
  
  
  
  1.15      +6 -8      httpd-python/src/connobject.c
  
  Index: connobject.c
  ===================================================================
  RCS file: /home/cvs/httpd-python/src/connobject.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- connobject.c	23 Jan 2003 22:34:18 -0000	1.14
  +++ connobject.c	17 Jul 2003 00:51:46 -0000	1.15
  @@ -113,8 +113,10 @@
   
       bb = apr_brigade_create(c->pool, c->bucket_alloc);
   
  +    bufsize = len == 0 ? HUGE_STRING_LEN : len;
  +
       Py_BEGIN_ALLOW_THREADS;
  -    rc = ap_get_brigade(c->input_filters, bb, mode, APR_BLOCK_READ, len);
  +    rc = ap_get_brigade(c->input_filters, bb, mode, APR_BLOCK_READ, bufsize);
       Py_END_ALLOW_THREADS;
   
       if (! APR_STATUS_IS_SUCCESS(rc)) {
  @@ -135,7 +137,6 @@
           return Py_None;
       }
   
  -    bufsize = len == 0 ? HUGE_STRING_LEN : len;
       result = PyString_FromStringAndSize(NULL, bufsize);
   
       /* possibly no more memory */
  @@ -180,7 +181,7 @@
   	}
   
   
  -        if (mode == AP_MODE_GETLINE) {
  +        if (mode == AP_MODE_GETLINE || len == 0) {
               apr_bucket_delete(b);
               break;
           }
  @@ -208,11 +209,8 @@
   
       long len = 0;
   
  -    if (! PyArg_ParseTuple(args, "l|i", &len)) 
  +    if (! PyArg_ParseTuple(args, "|l", &len)) 
           return NULL;
  -
  -    if (len == 0)
  -        return PyString_FromString("");
   
       if (len == -1)
           return _conn_read(self->conn, AP_MODE_EXHAUSTIVE, 0);
  
  
  
  1.91      +46 -3     httpd-python/src/mod_python.c
  
  Index: mod_python.c
  ===================================================================
  RCS file: /home/cvs/httpd-python/src/mod_python.c,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- mod_python.c	29 May 2003 14:15:47 -0000	1.90
  +++ mod_python.c	17 Jul 2003 00:51:46 -0000	1.91
  @@ -321,6 +321,40 @@
   }
   
   /**
  + ** python_create_global_config
  + **
  + *      This creates the part of config that survives
  + *  server restarts
  + *
  + */
  +
  +static py_global *python_create_global_config(server_rec *s)
  +{
  +    apr_pool_t *pool = s->process->pool;
  +    py_global *glb;
  +
  +    /* do we already have it in s->process->pool? */
  +
  +    apr_pool_userdata_get((void **)&glb, MP_CONFIG_KEY, pool);
  +
  +    if (glb) {
  +        return glb; 
  +    }
  +
  +
  +    /* otherwise, create it */
  +
  +    glb = (py_global *)apr_palloc(pool, sizeof(*glb));
  +    glb->shm_file = "/tmp/mod_python.shm"; //XXX
  +    glb->shm_size = 64000; //XXX
  +    glb->shm = NULL;
  +    glb->rmm = NULL;
  +    glb->table = NULL;
  +
  +    return glb;
  +}
  +
  +/**
    ** python_init()
    **
    *      Called by Apache at mod_python initialization time.
  @@ -375,11 +409,16 @@
           /* release the lock; now other threads can run */
           PyEval_ReleaseLock();
   #endif
  -/* XXX		PSP_PG(files) = PyDict_New(); */
  +
       }
  +
  +    python_create_global_config(s);
  +    /* table_rmm_init(s, p); */
  +
       return OK;
   }
   
  +
   /**
    ** python_create_config
    **
  @@ -397,11 +436,11 @@
       conf->hlists = apr_hash_make(p);
       conf->in_filters = apr_hash_make(p);
       conf->out_filters = apr_hash_make(p);
  +    conf->global = NULL;
   
       return conf;
   }
   
  -
   /**
    ** python_create_dir_config
    **
  @@ -437,6 +476,8 @@
   
       py_config *conf = python_create_config(p);
   
  +    conf->global = python_create_global_config(srv);
  +
       return conf;
   }
   
  @@ -520,6 +561,8 @@
           apr_hash_this(hi, (const void**)&key, &klen, (void **)&hle);
           apr_hash_set(merged_conf->out_filters, key, klen, (void *)hle);
       }
  +
  +    merged_conf->global = nc->global ? nc->global : cc->global;
   
       return (void *) merged_conf;
   }
  
  
  
  1.31      +21 -2     httpd-python/src/include/mod_python.h
  
  Index: mod_python.h
  ===================================================================
  RCS file: /home/cvs/httpd-python/src/include/mod_python.h,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- mod_python.h	29 May 2003 14:15:52 -0000	1.30
  +++ mod_python.h	17 Jul 2003 00:51:46 -0000	1.31
  @@ -82,6 +82,8 @@
   #include "apr_strings.h"
   #include "apr_lib.h"
   #include "apr_hash.h"
  +#include "apr_rmm.h"
  +#include "apr_shm.h"
   #include "scoreboard.h"
   
   /* Python headers */
  @@ -119,8 +121,10 @@
   #include "_apachemodule.h"
   #include "_pspmodule.h"
   
  +
   /** Things specific to mod_python, as an Apache module **/
   
  +#define MP_CONFIG_KEY "python_module"
   #define VERSION_COMPONENT "mod_python/" MPV_STRING
   #define MODULENAME "mod_python.apache"
   #define INITFUNC "init"
  @@ -142,16 +146,27 @@
       PyObject *obcallback;
   } interpreterdata;
   
  +/* Shared memory info */
  +typedef struct
  +{
  +    char      *shm_file;
  +    apr_size_t shm_size;
  +    apr_shm_t *shm;
  +    apr_rmm_t *rmm;
  +    apr_table_t *table;
  +} py_global;
  +
   /* structure describing per directory configuration parameters */
   typedef struct {
       int           authoritative;
       char         *config_dir;
       apr_table_t  *directives;
       apr_table_t  *options;
  -    apr_hash_t   *hlists; /* hlists for every phase */
  +    apr_hash_t   *hlists;   /* hlists for every phase */
       apr_hash_t   *in_filters;
       apr_hash_t   *out_filters;
       hl_entry     *imports;  /* for PythonImport */
  +    py_global    *global;
   } py_config;
   
   /* register_cleanup info */
  @@ -187,5 +202,9 @@
   } py_handler;
   
   apr_status_t python_cleanup(void *data);
  +
  +void table_rmm_init(server_rec *s, apr_pool_t *p);
  +int table_rmm_store(server_rec *s, char *key, char *val);
  +char *table_rmm_retrieve(server_rec *s, char *key);
   
   #endif /* !Mp_MOD_PYTHON_H */
  
  
  
  1.7       +1 -6      httpd-python/src/include/tableobject.h
  
  Index: tableobject.h
  ===================================================================
  RCS file: /home/cvs/httpd-python/src/include/tableobject.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- tableobject.h	8 Nov 2002 00:15:11 -0000	1.6
  +++ tableobject.h	17 Jul 2003 00:51:46 -0000	1.7
  @@ -70,11 +70,6 @@
   /*
    * This is a mapping of a Python object to an Apache table.
    *
  - * This object behaves like a dictionary. Note that the
  - * underlying table can have duplicate keys, which can never
  - * happen to a Python dictionary. But this is such a rare thing 
  - * that I can't even think of a possible scenario or implications.
  - *
    */
   
       typedef struct tableobject {