1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-09 21:54:09 +00:00

More win32 portability fixes. we now talk to tracker & peers; hash checks work, downloads seem to work. w00t

This commit is contained in:
Charles Kerr 2007-08-02 23:33:40 +00:00
parent 1af17214c9
commit ef2fc4fdcf
5 changed files with 25 additions and 15 deletions

View file

@ -167,7 +167,7 @@ tr_fastResumeSave( const tr_torrent_t * tor )
uint64_t total;
fastResumeFileName( path, sizeof path, tor, 1 );
file = fopen( path, "w" );
file = fopen( path, "wb" );
if( NULL == file ) {
tr_err( "Couldn't open '%s' for writing", path );
return;
@ -468,13 +468,13 @@ fastResumeLoadImpl ( tr_torrent_t * tor,
/* Open resume file */
fastResumeFileName( path, sizeof path, tor, 1 );
file = fopen( path, "r" );
file = fopen( path, "rb" );
if( !file )
{
if( ENOENT == errno )
{
fastResumeFileName( path, sizeof path, tor, 0 );
file = fopen( path, "r" );
file = fopen( path, "rb" );
if( !file )
{
fastResumeFileName( path, sizeof path, tor, 1 );

View file

@ -429,6 +429,7 @@ static int TrOpenFile( int i, const char * folder, const char * name, int write
struct stat sb;
char path[MAX_PATH_LENGTH];
int ret;
int flags;
tr_dbg( "Opening %s in %s (%d)", name, folder, write );
@ -448,7 +449,7 @@ static int TrOpenFile( int i, const char * folder, const char * name, int write
char * p = path + strlen( folder ) + 1;
char * s;
while( ( s = strchr( p, '/' ) ) )
while( ( s = strchr( p, TR_PATH_DELIMITER ) ) )
{
*s = '\0';
if( stat( path, &sb ) )
@ -468,14 +469,19 @@ static int TrOpenFile( int i, const char * folder, const char * name, int write
return TR_ERROR_IO_OTHER;
}
}
*s = '/';
*s = TR_PATH_DELIMITER;
p = s + 1;
}
}
/* Now try to really open the file */
errno = 0;
file->file = open( path, write ? ( O_RDWR | O_CREAT ) : O_RDONLY, 0666 );
flags = 0;
#ifdef WIN32
flags |= O_BINARY;
#endif
flags |= write ? (O_RDWR | O_CREAT) : O_RDONLY;
file->file = open( path, flags, 0666 );
if( write && ( file->file < 0 ) )
{
ret = tr_ioErrorFromErrno();

View file

@ -306,9 +306,12 @@ tr_netOpen( const struct in_addr * addr, tr_port_t port,
sock.sin_addr.s_addr = addr->s_addr;
sock.sin_port = port;
if( connect( s, (struct sockaddr *) &sock,
sizeof( struct sockaddr_in ) ) < 0 &&
sockerrno != EINPROGRESS )
if( ( connect( s, (struct sockaddr *) &sock,
sizeof( struct sockaddr_in ) ) < 0 )
#ifdef WIN32
&& ( sockerrno != WSAEWOULDBLOCK )
#endif
&& ( sockerrno != EINPROGRESS ) )
{
tr_err( "Couldn't connect socket (%s)", strerror( sockerrno ) );
tr_netClose( s );

View file

@ -748,7 +748,7 @@ getroute( int * buflen )
if( ENOENT != errno )
{
tr_err( "sysctl net.route.0.inet.flags.gateway failed (%s)",
strerror( errno ) );
strerror( sockerrno ) );
}
*buflen = 0;
return NULL;
@ -764,7 +764,7 @@ getroute( int * buflen )
if( sysctl( mib, 6, buf, &len, NULL, 0 ) )
{
tr_err( "sysctl net.route.0.inet.flags.gateway failed (%s)",
strerror( errno ) );
strerror( sockerrno ) );
free( buf );
*buflen = 0;
return NULL;
@ -894,14 +894,14 @@ getsock( void )
fd = socket( PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE );
if( 0 > fd )
{
tr_err( "failed to create routing socket (%s)", strerror( errno ) );
tr_err( "failed to create routing socket (%s)", strerror( sockerrno ) );
return -1;
}
flags = fcntl( fd, F_GETFL );
if( 0 > flags || 0 > fcntl( fd, F_SETFL, O_NONBLOCK | flags ) )
{
tr_err( "failed to set socket nonblocking (%s)", strerror( errno ) );
tr_err( "failed to set socket nonblocking (%s)", strerror( sockerrno ) );
close( fd );
return -1;
}
@ -920,7 +920,7 @@ getsock( void )
if( 0 > sendto( fd, &req, sizeof( req ), 0,
(struct sockaddr *) &snl, sizeof( snl ) ) )
{
tr_err( "failed to write to routing socket (%s)", strerror( errno ) );
tr_err( "failed to write to routing socket (%s)", strerror( sockerrno ) );
close( fd );
return -1;
}

View file

@ -48,7 +48,7 @@
static tr_lock_t * messageLock = NULL;
static int messageLevel = 0;
static int messageQueuing = 0;
static int messageQueuing = FALSE;
static tr_msg_list_t * messageQueue = NULL;
static tr_msg_list_t ** messageQueueTail = &messageQueue;
@ -160,6 +160,7 @@ void tr_msg( int level, char * msg, ... )
{
vfprintf( stderr, msg, args1 );
fputc( '\n', stderr );
fflush( stderr );
}
va_end( args1 );
}