Looking for direction
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Looking for direction




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Looking for direction  
Douglas Dillon


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-20-05 11:20 PM

I have inherited an app that retrieves data for applets and is having
trouble running multiple sessions. I have located the problem but
being new to this field need help understanding why it occurs.

I've cut the code to make it more readable. The problem occurs when
you try to create a second connection at "data->in = fdopen(socket,
"rb");" . The statement will not return until the previous applet has
committed an action.

pthread_t *thread;
pthread_attr_t attr;

length = sizeof(struct sockaddr_in);
socket = accept(tcp_sock, (struct sockaddr *) &client_addr, &length);

if (setsockopt(socket, SOL_TCP, TCP_NODELAY, &nodelay,
sizeof(nodelay)) < 0) error("Error setting connection socket option
2");
if (setsockopt(socket, SOL_SOCKET, SO_SNDBUF, &bufsize,
sizeof(bufsize)) < 0) error("Error setting connection socket option
6");
if (setsockopt(socket, SOL_SOCKET, SO_RCVBUF, &bufsize,
sizeof(bufsize)) < 0) error("Error setting connection socket option
7");

pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (NUM_USERS < MAX_USERS / 5) { // first 20% users get faster system
I/O threads if allowed
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
} else {
pthread_attr_setscope(&attr, PTHREAD_SCOPE_PROCESS);
};
thread = malloc(sizeof(pthread_t));

thread_data *data =  (thread_data *)malloc(sizeof(thread_data));
data->data_socket = socket;
data->in = fdopen(socket, "rb");
data->out = fdopen(socket, "wb");
pthread_create(thread, &attr, Service_Thread, (void *) data);
pthread_attr_destroy(&attr);

Thanks,

Douglas





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 05:41 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register