Patch for FreeBSD, thanks to Markus Strobl.

git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@28 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez 2006-07-03 14:02:29 +00:00
parent cf9ae4f6e5
commit 90c3db2a96
7 changed files with 64 additions and 18 deletions

View File

@ -1,3 +1,7 @@
2006-07-03 Marcelo Jimenez <mroberto@users.sourceforge.net>
* Patch for FreeBSD, thanks to Markus Strobl.
2006-06-26 Marcelo Jimenez <mroberto@users.sourceforge.net> 2006-06-26 Marcelo Jimenez <mroberto@users.sourceforge.net>
* Fix for missing "else" in httpreadwrite.c. Thanks to npapadop * Fix for missing "else" in httpreadwrite.c. Thanks to npapadop

View File

@ -30,7 +30,11 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#include "LinkedList.h" #include "LinkedList.h"
#ifdef __FreeBSD__
#include <stdlib.h>
#else
#include <malloc.h> #include <malloc.h>
#endif
#include <assert.h> #include <assert.h>
static int static int

View File

@ -345,10 +345,12 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
struct timeb t; struct timeb t;
ftime( &t ); ftime( &t );
#ifndef WIN32 #if defined(WIN32)
srand( ( unsigned int )t.millitm + ithread_get_current_thread_id( ) );
#else
srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id( ).p ); srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id( ).p );
#elif defined(__FreeBSD__)
srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id( ) );
#else
srand( ( unsigned int )t.millitm + ithread_get_current_thread_id( ) );
#endif #endif
} }
@ -1463,7 +1465,11 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
assert( stats != NULL ); if( stats == NULL ) { assert( stats != NULL ); if( stats == NULL ) {
return;} return;}
#ifdef __FreeBSD__
printf( "ThreadPoolStats at Time: %d\n", time( NULL ) );
#else
printf( "ThreadPoolStats at Time: %ld\n", time( NULL ) ); printf( "ThreadPoolStats at Time: %ld\n", time( NULL ) );
#endif
printf printf
( "Average Wait in High Priority Q in milliseconds: %lf\n", ( "Average Wait in High Priority Q in milliseconds: %lf\n",
stats->avgWaitHQ ); stats->avgWaitHQ );

View File

@ -31,7 +31,11 @@
#include <stdarg.h> #include <stdarg.h>
#include <assert.h> #include <assert.h>
#ifdef __FreeBSD__
#include <stdlib.h>
#else
#include <malloc.h> #include <malloc.h>
#endif
#include <stdio.h> #include <stdio.h>
#include "iasnprintf.h" #include "iasnprintf.h"

View File

@ -37,6 +37,9 @@
//@{ //@{
#include <stdio.h> #include <stdio.h>
#ifdef __FreeBSD__
#include <time.h>
#endif
#include "ixml.h" #include "ixml.h"
#include "upnpconfig.h" #include "upnpconfig.h"
#if UPNP_HAVE_DEBUG #if UPNP_HAVE_DEBUG

View File

@ -33,6 +33,9 @@
* Purpose: This file contains functions for uri, url parsing utility. * Purpose: This file contains functions for uri, url parsing utility.
************************************************************************/ ************************************************************************/
#ifdef __FreeBSD__
#include <lwres/netdb.h>
#endif
#include "config.h" #include "config.h"
#include "uri.h" #include "uri.h"
@ -608,21 +611,27 @@ parse_hostport( char *in,
int errCode = 0; int errCode = 0;
//call gethostbyname_r (reentrant form of gethostbyname) //call gethostbyname_r (reentrant form of gethostbyname)
#ifdef WIN32 #if defined(WIN32)
h=gethostbyname(temp_host_name); h=gethostbyname(temp_host_name);
#else #elif defined(SPARC_SOLARIS)
#ifndef SPARC_SOLARIS errCode = gethostbyname_r( temp_host_name,
errCode = gethostbyname_r( temp_host_name, &h,
&h_buf, temp_hostbyname_buff,
temp_hostbyname_buff, BUFFER_SIZE, &errcode );
BUFFER_SIZE, &h, &errcode ); #elif defined(__FreeBSD__)
#else h = lwres_gethostbyname_r( temp_host_name,
errCode = gethostbyname_r( temp_host_name, &h_buf,
&h, temp_hostbyname_buff,
temp_hostbyname_buff, BUFFER_SIZE, &errcode );
BUFFER_SIZE, &errcode ); if ( h == NULL ) {
#endif errCode = 1;
#endif }
#else
errCode = gethostbyname_r( temp_host_name,
&h_buf,
temp_hostbyname_buff,
BUFFER_SIZE, &h, &errcode );
#endif
if( errCode == 0 ) { if( errCode == 0 ) {
if( h ) { if( h ) {

View File

@ -960,6 +960,22 @@ get_ssdp_sockets( MiniServerSockArray * out )
UpnpCloseSocket( ssdpSock ); UpnpCloseSocket( ssdpSock );
return UPNP_E_SOCKET_ERROR; return UPNP_E_SOCKET_ERROR;
} }
#ifdef __FreeBSD__
if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEPORT,
( char * )&onOff, sizeof( onOff ) ) != 0 ) {
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
SSDP, __FILE__, __LINE__,
"Error in set reuse port !!!\n" );
)
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
shutdown( ssdpSock, SD_BOTH );
UpnpCloseSocket( ssdpSock );
return UPNP_E_SOCKET_ERROR;
}
#endif
memset( ( void * )&ssdpAddr, 0, sizeof( struct sockaddr_in ) ); memset( ( void * )&ssdpAddr, 0, sizeof( struct sockaddr_in ) );
ssdpAddr.sin_family = AF_INET; ssdpAddr.sin_family = AF_INET;