Sponsored Content
Top Forums Programming Timeout with multithread server Post 20429 by Nads on Friday 26th of April 2002 07:18:35 AM
Old 04-26-2002
Timeout with multithread server

I wrote a server which creates a thread for every client connection. I have to include timeout function that will kill the server thread if the client doesn't respond for specific time. That too using signal(SIGALRM). For this i am using alarm() function.
When the server thread detects signal it calls the signal handler.
Problem i am facing is that: the signal handler function will be common to all threads. In that case how to do some cleanup functions for perticular server thread? (signal number is the only input to signalhandler)

i hope i explained my problem clearly
if anyone has given a thought on this problem, kindly help me out...
thanks in advance....
 

10 More Discussions You Might Find Interesting

1. Programming

Multithread,libcurl

Hi i m codding a programm,it can download any packet from ftp,I use libcurl library. But i want to use threads for downloading.(Multithreading).i cant get ftp file size from ftp and divide packet small pieces,like threads use. Please share your experince with me ,thanks. (0 Replies)
Discussion started by: canerbulut
0 Replies

2. Programming

Multithread app - Read-Only Data

Hello, I'm coding an application using pthreads.At some point the threads will read some read-only variables.Is it safe NOT to use mutexes, in order to make the program lighter since mutex operations are resource-demanding... Thanks (1 Reply)
Discussion started by: jonas.gabriel
1 Replies

3. Shell Programming and Scripting

SNMP Timeout: No Response from server

When I tried to connect snmp from one server to another server Timeout: No Response from server is comming Pls suggest (0 Replies)
Discussion started by: madhusmita
0 Replies

4. Programming

[C] Multithread Server

Hi all,i'm new on this forum, excuse me for my english. I have wrote a server that accept connection from multiple client with the fork,but every client had to insert data in a linear list. The problem is that every client insert data in an own copy of the linear list and this is caused by... (7 Replies)
Discussion started by: kemistry
7 Replies

5. AIX

ftp timeout valiue in AIX 5.3 server !

Dear Friends, I am using AIX 5.3 server . In AIX , I want to increase the timeout value of the ftp service . But I cannot find any configuration file with ftp related in AIX 5.3 server . Would anybody plz tell me , How can I increase the default timeout value in AIX ? (2 Replies)
Discussion started by: shipon_97
2 Replies

6. Shell Programming and Scripting

Bash script multithread in group of 3

I Have an script like ./bang 1 ./bang 2 ./bang 3 ./bang 4 ./bang 5 ./bang 6 ./bang 7 ./bang 8 ./bang 9 ./bang 10 ./bang 11 ./bang 12 and i wanna execute him in groups of 3 , i mean he execute bang 1 , bang 2 and bang 3 after it finish the next 3 commands it will be executed and... (5 Replies)
Discussion started by: Gyeah11
5 Replies

7. IP Networking

TFTP Server Timeout issue

Hi, I'm running CentOS 5 as guest using VMware player. My host is Windows Xp. I'm running tftp server in CentOS. I have disabled firewall in both windows and CentOS. I use two different networks with different netmasks on CentOS. I'm able to ping the Centos (tftp server) from another Linux machine... (1 Reply)
Discussion started by: suryaemlinux
1 Replies

8. Solaris

Session timeout setting in server

Hi All I need to set timeout of login session of a user if a user is idle for some time. I know the TMOUT setting but it work with only BASH & KORN shell only as I need to set for Bourne shell also. I am trying to put "ClientAliveInterval 300" in sshd_config & restart or refreshing the... (1 Reply)
Discussion started by: sb200
1 Replies

9. AIX

Able to ping the server but not able to login through putty it says network timeout

Able to ping the server but not able to login through putty it says network timeout Please assist (3 Replies)
Discussion started by: Vishal_dba
3 Replies

10. AIX

AIX 5.3 NFS export not mounting, rpcinfo hang/timeout on server

Been trying to get a directory NFS-mounted with no success. I've tried both NFS v3 and v4, but currently trying v4. I can't figure out what's going on here. server: sbkovwadmd01 sbkovwadmd01# chnfsdom Current local domain: edw.dev sbkovwadmd01# lssrc -a | grep nfs | grep active nfsd ... (3 Replies)
Discussion started by: eckertd
3 Replies
door_server_create(3DOOR)                                     Door Library Functions                                     door_server_create(3DOOR)

NAME
door_server_create - specify an alternative door server thread creation function SYNOPSIS
cc -mt [ flag ... ] file ... -ldoor [ library ... ] #include <door.h> void (*) () door_server_create(void (*create_proc)(door_info_t*)); DESCRIPTION
Normally, the doors library creates new door server threads in response to incoming concurrent door invocations automatically. There is no pre-defined upper limit on the number of server threads that the system creates in response to incoming invocations (1 server thread for each active door invocation). These threads are created with the default thread stack size and POSIX (see standards(5)) threads cancella- tion disabled. The created threads also have the THR_BOUND | THR_DETACHED attributes for Solaris threads and the PTHREAD_SCOPE_SYSTEM | PTHREAD_CREATE_DETACHED attributes for POSIX threads. The signal disposition, and scheduling class of the newly created thread are inherited from the calling thread (initially from the thread calling door_create(), and subsequently from the current active door server thread). The door_server_create() function allows control over the creation of server threads needed for door invocations. The procedure create_proc is called every time the available server thread pool is depleted. In the case of private server pools associated with a door (see the DOOR_PRIVATE attribute in door_create()), information on which pool is depleted is passed to the create function in the form of a door_info_t structure. The di_proc and di_data members of the door_info_t structure can be used as a door identifier associated with the depleted pool. The create_proc procedure may limit the number of server threads created and may also create server threads with appropri- ate attributes (stack size, thread-specific data, POSIX thread cancellation, signal mask, scheduling attributes, and so forth) for use with door invoca- tions. The specified server creation function should create user level threads using thr_create() with the THR_BOUND flag, or in the case of POSIX threads, pthread_create() with the PTHREAD_SCOPE_SYSTEM attribute. The server threads make themselves available for incoming door invocations on this process by issuing a door_return(NULL, 0, NULL, 0). In this case, the door_return() arguments are ignored. See door_return(3DOOR) and thr_create(3C). The server threads created by default are enabled for POSIX thread cancellations which may lead to unexpected thread terminations while holding resources (such as locks) if the client aborts the associated door_call(). See door_call(3DOOR). Unless the server code is truly interested in notifications of client aborts during a door invocation and is prepared to handle such notifications using cancellation handlers, POSIX thread cancellation should be disabled for server threads using pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL). The create_proc procedure need not create any additional server threads if there is at least one server thread currently active in the process (perhaps handling another door invocation) or it may create as many as seen fit each time it is called. If there are no available server threads during an incoming door invocation, the associated door_call() blocks until a server thread becomes available. The cre- ate_proc procedure must be MT-Safe. RETURN VALUES
Upon successful completion, door_server_create() returns a pointer to the previous server creation function. This function has no failure mode (it cannot fail). EXAMPLES
Example 1: Creating door server threads. The following example creates door server threads with cancellation disabled and an 8k stack instead of the default stack size: #include <door.h> #include <pthread.h> #include <thread.h> void * my_thread(void *arg) { pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); door_return(NULL, 0, NULL, 0); } void my_create(door_info_t *dip) { thr_create(NULL, 8192, my_thread, NULL, THR_BOUND | THR_DETACHED, NULL); } main() { (void)door_server_create(my_create); ... } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Architecture |all | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
door_bind(3DOOR), door_call(3DOOR), door_create(3DOOR), door_return(3DOOR), libdoor(3LIB), pthread_create(3C), pthread_setcancelstate(3C), thr_create(3C), attributes(5), cancellation(5), standards(5) SunOS 5.10 20 Aug 1997 door_server_create(3DOOR)
All times are GMT -4. The time now is 03:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy