Browse Source

fix some issues

pull/359/head
Max Lv 9 years ago
parent
commit
2c0dd4a33d
3 changed files with 22 additions and 10 deletions
  1. 18
      src/android.c
  2. 10
      src/common.h
  3. 4
      src/local.c

18
src/android.c

@ -29,6 +29,15 @@
#include <strings.h>
#include <unistd.h>
#include <errno.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/un.h>
#include <ancillary.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -53,7 +62,7 @@ static struct remote * new_remote(int fd, int timeout);
static void free_remote(struct remote *remote);
static void close_and_free_remote(EV_P_ struct remote *remote);
int verbose = 0;
extern int verbose;
static int setnonblocking(int fd)
{
@ -94,7 +103,7 @@ static void remote_recv_cb(EV_P_ ev_io *w, int revents)
}
remote->protect_cb(ret, remote->data);
close_and_free_remote(remote);
close_and_free_remote(EV_A_ remote);
}
static void remote_send_cb(EV_P_ ev_io *w, int revents)
@ -102,6 +111,9 @@ static void remote_send_cb(EV_P_ ev_io *w, int revents)
struct remote_ctx *remote_send_ctx = (struct remote_ctx *)w;
struct remote *remote = remote_send_ctx->remote;
struct sockaddr_storage addr;
socklen_t len = sizeof addr;
int r = getpeername(remote->fd, (struct sockaddr *)&addr, &len);
if (r == 0) {
@ -191,7 +203,7 @@ int protect_socket(void (*protect_cb)(int ret, void *data), void *data, int fd)
if (connect(remotefd, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
LOGE("[android] connect() failed: %s (fd = %d)\n", strerror(errno), remotefd);
close(remotefd);
return -1
return -1;
}
// listen to remote connected event

10
src/common.h

@ -19,8 +19,8 @@
* <http://www.gnu.org/licenses/>.
*/
#ifndef _INCLUDE_H
#define _INCLUDE_H
#ifndef _COMMON_H
#define _COMMON_H
// only enable TCP_FASTOPEN on linux
#if __linux
@ -58,4 +58,8 @@ int init_udprelay(const char *server_host, const char *server_port,
void free_udprelay(void);
#endif // _INCLUDE_H
#ifdef ANDROID
int protect_socket(void (*protect_cb)(int ret, void *data), void *data, int fd);
#endif
#endif // _COMMON_H

4
src/local.c

@ -67,10 +67,6 @@
#include "acl.h"
#include "local.h"
#ifdef ANDROID
#include "android.h"
#endif
#ifndef EAGAIN
#define EAGAIN EWOULDBLOCK
#endif

Loading…
Cancel
Save