am c6091d6b: Merge "adb: Win32: set socket buffer sizes properly"

* commit 'c6091d6bfd1c74df7f5352b3de2b3dbdd64a98bd':
  adb: Win32: set socket buffer sizes properly
This commit is contained in:
Elliott Hughes 2015-01-27 18:33:49 +00:00 committed by Android Git Automerger
commit a3029782d4
3 changed files with 31 additions and 11 deletions

View File

@ -472,7 +472,7 @@ int adb_download_buffer(const char *service, const char *fn, const void* data, i
}
int opt = CHUNK_SIZE;
opt = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (const void *) &opt, sizeof(opt));
opt = adb_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (const void *) &opt, sizeof(opt));
total = sz;
ptr = data;
@ -581,7 +581,7 @@ int adb_sideload_host(const char* fn) {
}
int opt = SIDELOAD_HOST_BLOCK_SIZE;
opt = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (const void *) &opt, sizeof(opt));
opt = adb_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (const void *) &opt, sizeof(opt));
int last_percent = -1;
for (;;) {

View File

@ -89,8 +89,6 @@ static __inline__ void close_on_exec(int fd)
/* nothing really */
}
extern void disable_tcp_nagle(int fd);
#define lstat stat /* no symlinks on Win32 */
#define S_ISLNK(m) 0 /* no symlinks on Win32 */
@ -210,10 +208,21 @@ extern int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t
#undef accept
#define accept ___xxx_accept
extern int adb_setsockopt(int fd, int level, int optname, const void* optval, socklen_t optlen);
#undef setsockopt
#define setsockopt ___xxx_setsockopt
static __inline__ int adb_socket_setbufsize( int fd, int bufsize )
{
int opt = bufsize;
return setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const char*)&opt, sizeof(opt));
return adb_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const void*)&opt, sizeof(opt));
}
static __inline__ void disable_tcp_nagle( int fd )
{
int on = 1;
adb_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const void*)&on, sizeof(on));
}
extern int adb_socketpair( int sv[2] );
@ -450,6 +459,13 @@ static __inline__ void disable_tcp_nagle(int fd)
setsockopt( fd, IPPROTO_TCP, TCP_NODELAY, (void*)&on, sizeof(on) );
}
static __inline__ int adb_setsockopt( int fd, int level, int optname, const void* optval, socklen_t optlen )
{
return setsockopt( fd, level, optname, optval, optlen );
}
#undef setsockopt
#define setsockopt ___xxx_setsockopt
static __inline__ int unix_socketpair( int d, int type, int protocol, int sv[2] )
{

View File

@ -440,7 +440,8 @@ int adb_shutdown(int fd)
{
FH f = _fh_from_int(fd);
if (!f) {
if (!f || f->clazz != &_fh_socket_class) {
D("adb_shutdown: invalid fd %d\n", fd);
return -1;
}
@ -471,6 +472,8 @@ int adb_close(int fd)
/**************************************************************************/
/**************************************************************************/
#undef setsockopt
static void
_socket_set_errno( void )
{
@ -786,15 +789,16 @@ int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t *addrle
}
void disable_tcp_nagle(int fd)
int adb_setsockopt( int fd, int level, int optname, const void* optval, socklen_t optlen )
{
FH fh = _fh_from_int(fd);
int on = 1;
if ( !fh || fh->clazz != &_fh_socket_class )
return;
if ( !fh || fh->clazz != &_fh_socket_class ) {
D("adb_setsockopt: invalid fd %d\n", fd);
return -1;
}
setsockopt( fh->fh_socket, IPPROTO_TCP, TCP_NODELAY, (const char*)&on, sizeof(on) );
return setsockopt( fh->fh_socket, level, optname, optval, optlen );
}
/**************************************************************************/