mirror of
https://github.com/lxsang/antd-tunnel-plugin
synced 2024-11-16 09:48:21 +01:00
cleanup code
This commit is contained in:
parent
a0347eac48
commit
4cdfaf5da2
BIN
dist/tunnel-0.1.0b.tar.gz
vendored
BIN
dist/tunnel-0.1.0b.tar.gz
vendored
Binary file not shown.
48
tunnel.c
48
tunnel.c
@ -79,54 +79,6 @@ typedef struct
|
||||
|
||||
static antd_tunnel_t g_tunnel;
|
||||
|
||||
static int guard_read(int fd, void* buffer, size_t size)
|
||||
{
|
||||
int n = 0;
|
||||
int read_len;
|
||||
int st;
|
||||
while(n != (int)size)
|
||||
{
|
||||
read_len = (int)size - n;
|
||||
st = read(fd,buffer + n,read_len);
|
||||
if(st == -1)
|
||||
{
|
||||
ERROR( "Unable to read from #%d: %s", fd, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if(st == 0)
|
||||
{
|
||||
ERROR("Endpoint %d is closed", fd);
|
||||
return -1;
|
||||
}
|
||||
n += st;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static int guard_write(int fd, void* buffer, size_t size)
|
||||
{
|
||||
int n = 0;
|
||||
int write_len;
|
||||
int st;
|
||||
while(n != (int)size)
|
||||
{
|
||||
write_len = (int)size - n;
|
||||
st = write(fd,buffer + n,write_len);
|
||||
if(st == -1)
|
||||
{
|
||||
ERROR("Unable to write to #%d: %s", fd, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if(st == 0)
|
||||
{
|
||||
ERROR("Endpoint %d is closed", fd);
|
||||
return -1;
|
||||
}
|
||||
n += st;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static int mk_socket(const char *name, char *path)
|
||||
{
|
||||
struct sockaddr_un address;
|
||||
|
Loading…
Reference in New Issue
Block a user