• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/genericProc/programs/libcprops/svc/cpsp_invoker.h

00001 #ifndef _CP_SVC_CPSP_INVOKER_H
00002 #define _CP_SVC_CPSP_INVOKER_H
00003 
00004 #include <sys/types.h>
00005 #include "cprops/common.h"
00006 #include "cprops/collection.h"
00007 #include "cprops/hashlist.h"
00008 #include "cprops/vector.h"
00009 #include "cprops/hashtable.h"
00010 
00011 
00012 typedef struct _cpsp_invoker_ctl
00013 {
00014         short running;
00015         cp_hashlist *available;
00016         cp_vector *workers;
00017         cp_hashtable *session_lookup;
00018         cp_hashtable *pid_lookup;
00019         cp_hashtable *session_keys;
00020         char *pwd;
00021         char *cpsp_bin_path;
00022         int max_workers;
00023         int curr_workers;
00024         short is_worker;
00025 
00026         cp_mutex worker_lock;
00027         cp_cond worker_cond;
00028 } cpsp_invoker_ctl;
00029 
00030 void init_cpsp_invoker(char *document_root, 
00031                                            char *cpsp_bin_path, 
00032                                            int workers, 
00033                                            int max_workers);
00034 
00035 void stop_cpsp_invoker();
00036 void shutdown_cpsp_invoker(void *ctl);
00037 
00038 typedef enum { REQUEST = 1, KEEPALIVE, SHUTDOWN } cpsp_cmd;
00039 typedef enum { RESPONSE = 1, RESPONSE_SESSION, KEEPALIVE_ACK } cpsp_cmd_response;
00040 
00041 /* the worker descriptor is somewhat different between the platforms that 
00042  * support fork() and socketpair() and the platform(s) that do(es)n't. 
00043  */
00044 typedef struct _worker_desc
00045 {
00046         int index;        /* workers are retrieved by index or by availability */
00047 #if defined(unix) || defined(__unix__) || defined(__MACH__)
00048         pid_t pid;
00049         int fd;
00050 #else
00051 #ifdef _WINDOWS
00052         HANDLE svc_in;
00053         HANDLE svc_out;
00054 #endif /* _WINDOWS */
00055 #endif /* unix */
00056         cp_list *session; /* sessions assigned to this worker */
00057 } worker_desc;
00058 
00059 /* the worker descriptor create function is somewhat different between the
00060  * platforms that support fork() and socketpair() and the platform(s) that 
00061  * do(es)n't. 
00062  */
00063 #if defined(unix) || defined(__unix__) || defined(__MACH__)
00064 worker_desc *worker_desc_create(int index, pid_t pid, int fd);
00065 #else
00066 #ifdef _WINDOWS
00067 worker_desc *worker_desc_create(int index, HANDLE svc_in, HANDLE svc_out);
00068 #endif /* _WINDOWS */
00069 #endif /* unix */
00070 
00071 /* the worker descriptor destruction function is the same on all platforms. */
00072 void worker_desc_destroy(worker_desc *desc);
00073 
00074 #if defined(unix) || defined(__unix__) || defined(__MACH__)
00075 void cpsp_worker_run(int fd);
00076 #endif
00077 
00078 #ifdef _WINDOWS
00079 void cpsp_worker_run(HANDLE in, HANDLE out);
00080 #endif
00081 
00082 int cpsp_invoke(cp_http_request *request, cp_http_response *response);
00083 
00084 typedef size_t (*serialize_fn)(cp_string *buf, void *item);
00085 typedef size_t (*deserialize_fn)(cp_string *buf, int offset, void **itemptr);
00086 
00087 #endif /* _CP_SVC_CPSP_INVOKER_H */

Generated on Fri Oct 22 2010 11:02:23 for SST by  doxygen 1.7.1