$Revision: 1.12 $
Example code: A thread.
Status: NOT REVUED, NOT TESTED
Authors: Chris Ottrey
Joao Damas
- Online References:
-
Included Files
- #include "include/socket.h"
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <stdlib.h>
- #include <errno.h>
- #include <netdb.h>
- #include <signal.h>
- #include <stdio.h>
- #include <include/iproutines.h>
- #include </space/dbdev/marek/include/glib.h>
- #include </space/dbdev/marek/lib/glib/include/glibconfig.h>
- #include <limits.h>
- #include <float.h>
- #include <stdarg.h>
- #include <include/erroutines.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <assert.h>
- #include <time.h>
- #include <stdarg.h>
- #include <strings.h>
- #include <include/bitmask.h>
- #include <include/er_aspects.h>
- #include <include/stubs.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include "include/er_facilities.h"
Preprocessor definitions
String sizes
#define STR_S 63
#define STR_M 255
#define STR_L 1023
#define STR_XL 4095
#define STR_XXL 16383
typedef struct th_args th_args
struct th_args |
|
{ |
|
void* function; |
|
int sock; |
|
} |
|
Mutex lock. Used for synchronizing changes.
pthread_mutex_t Whois_thread_count_lock
pthread_mutex_t Config_thread_count_lock
pthread_mutex_t Mirror_thread_count_lock
The number of threads.
int Whois_thread_count
int Config_thread_count
int Mirror_thread_count
Aquire a readers lock.
Reference: "Multithreaded Programming Techniques - Prasad p.192"
More:
Author:
ottrey
void TH_acquire_read_lock ( rw_lock_t* prw_lock )
- rw_lock_t* prw_lock
- Readers writers lock.
Aquire a writers lock.
Reference: "Multithreaded Programming Techniques - Prasad p.192"
More:
Author:
ottrey
void TH_acquire_write_lock ( rw_lock_t* prw_lock )
- rw_lock_t* prw_lock
- Readers writers lock.
Handle config connections.
More:
Author:
joao
void TH_do_config ( void* arg )
- void* arg
- The socket to connect to. (It has to be passed in this way for this
thread routine.)
Handle whois connections.
More:
Author:
joao
void TH_do_whois ( void* arg )
- void* arg
- The socket to connect to. (It has to be passed in this way for this thread routine.)
int TH_get_id ( void )
Handle signals.
Changes the flags:
do_nrtm
do_update
do_whoisd
More:
Author:
andrei
void TH_hdl_signal ( void )
Initialize a readers/writers lock.
Side effect: the lock is set to open(?)
Reference: "Multithreaded Programming Techniques - Prasad p.192"
More:
Author:
ottrey
void TH_init_read_write_lock ( rw_lock_t* prw_lock )
- rw_lock_t* prw_lock
- Readers writers lock.
Release a readers lock.
Reference: "Multithreaded Programming Techniques - Prasad p.192"
More:
Author:
ottrey
void TH_release_read_lock ( rw_lock_t* prw_lock )
- rw_lock_t* prw_lock
- Readers writers lock.
Release a writers lock.
Reference: "Multithreaded Programming Techniques - Prasad p.192"
More:
Author:
ottrey
void TH_release_write_lock ( rw_lock_t* prw_lock )
- rw_lock_t* prw_lock
- Readers writers lock.
This is the routine that creates the main threads.
More:
Author:
ottrey
joao
void TH_run ( int sock, void* do_function(void*) )
- int sock
- The socket to connect to.
void * do_function The function to call for each type of service
- void* do_function(void*)
-
This is the routine that creates 1 main thread.
More:
Author:
ottrey
joao
andrei
void TH_run1 ( int sock, void* do_function(void*) )
- int sock
- The socket to listen to.
void * do_function The function to call for each type of service
- void* do_function(void*)
-
void TH_run2 ( void* function(void*) )
char* TH_to_string ( void )
static void log_print ( const char* arg )
Waits for an incoming connection on the and spawns a new thread to handle it.
More:
Author:
ottrey
joao
static void* main_thread ( void* arg )
- void* arg
- Pointer to a struct containing the socket to talk to the client and
the function to call depending on the incoming connection.