Apply patch from Kaori. Thanks.

This commit is contained in:
Mathieu Malaterre 2011-12-23 08:29:09 +00:00
parent 7e6c287d78
commit f26b96dd5c
2 changed files with 28 additions and 24 deletions

View File

@ -5,6 +5,9 @@ What's New for OpenJPIP
! : changed ! : changed
+ : added + : added
December 22, 2011
* [kaori] fixed auxtrans_manager to enable MAC
November 30, 2011 November 30, 2011
+ [kaori] TCP return (http-tcp) implemented + [kaori] TCP return (http-tcp) implemented

View File

@ -33,10 +33,10 @@
#include <stdlib.h> #include <stdlib.h>
#include "auxtrans_manager.h" #include "auxtrans_manager.h"
#ifdef __linux__ #ifdef _WIN32
#include <pthread.h>
#else
#include <process.h> #include <process.h>
#else
#include <pthread.h>
#endif #endif
#ifdef SERVER #ifdef SERVER
@ -94,20 +94,21 @@ aux_response_param_t * gene_auxresponse( bool istcp, auxtrans_param_t auxtrans,
void delete_auxresponse( aux_response_param_t **auxresponse); void delete_auxresponse( aux_response_param_t **auxresponse);
#ifdef __linux__
void * aux_streaming( void *arg); #ifdef _WIN32
#else
unsigned __stdcall aux_streaming( void *arg); unsigned __stdcall aux_streaming( void *arg);
#else
void * aux_streaming( void *arg);
#endif #endif
void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame) void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame)
{ {
aux_response_param_t *auxresponse; aux_response_param_t *auxresponse;
#ifdef __linux__ #ifdef _WIN32
unsigned int threadId;
#else
pthread_t thread; pthread_t thread;
int status; int status;
#else
unsigned int threadId;
#endif #endif
if( istcp){ if( istcp){
@ -117,15 +118,15 @@ void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, char cid[]
} }
auxresponse = gene_auxresponse( istcp, auxtrans, cid, data, datalen, maxlenPerFrame); auxresponse = gene_auxresponse( istcp, auxtrans, cid, data, datalen, maxlenPerFrame);
#ifdef __linux__ #ifdef _WIN32
status = pthread_create( &thread, NULL, &aux_streaming, auxresponse);
if( status != 0)
fprintf( FCGI_stderr,"ERROR: pthread_create() %s",strerror(status));
#else
auxresponse->hTh = (HANDLE)_beginthreadex( NULL, 0, &aux_streaming, auxresponse, 0, &threadId); auxresponse->hTh = (HANDLE)_beginthreadex( NULL, 0, &aux_streaming, auxresponse, 0, &threadId);
if( auxresponse->hTh == 0) if( auxresponse->hTh == 0)
fprintf( FCGI_stderr,"ERRO: pthread_create() %s", strerror( (int)auxresponse->hTh)); fprintf( FCGI_stderr,"ERRO: pthread_create() %s", strerror( (int)auxresponse->hTh));
#else
status = pthread_create( &thread, NULL, &aux_streaming, auxresponse);
if( status != 0)
fprintf( FCGI_stderr,"ERROR: pthread_create() %s",strerror(status));
#endif #endif
} }
else else
@ -166,10 +167,10 @@ bool identify_cid( SOCKET connected_socket, char refcid[], FILE *fp);
bool recv_ack( SOCKET connected_socket, void *data); bool recv_ack( SOCKET connected_socket, void *data);
#ifdef __linux__ #ifdef _WIN32
void * aux_streaming( void *arg)
#else
unsigned __stdcall aux_streaming( void *arg) unsigned __stdcall aux_streaming( void *arg)
#else
void * aux_streaming( void *arg)
#endif #endif
{ {
SOCKET connected_socket; SOCKET connected_socket;
@ -179,10 +180,10 @@ unsigned __stdcall aux_streaming( void *arg)
aux_response_param_t *auxresponse = (aux_response_param_t *)arg; aux_response_param_t *auxresponse = (aux_response_param_t *)arg;
#ifdef __linux__ #ifdef _WIN32
pthread_detach( pthread_self());
#else
CloseHandle( auxresponse->hTh); CloseHandle( auxresponse->hTh);
#else
pthread_detach( pthread_self());
#endif #endif
chunk = (unsigned char *)malloc( auxresponse->maxlenPerFrame); chunk = (unsigned char *)malloc( auxresponse->maxlenPerFrame);
@ -219,10 +220,10 @@ unsigned __stdcall aux_streaming( void *arg)
delete_auxresponse( &auxresponse); delete_auxresponse( &auxresponse);
#ifdef __linux__ #ifdef _WIN32
pthread_exit(0);
#else
_endthreadex(0); _endthreadex(0);
#else
pthread_exit(0);
#endif #endif
return 0; return 0;