Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
twose committed Oct 15, 2019
2 parents ba1c078 + 7c39e7a commit 91a9e03
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ int swSocket_wait(int fd, int timeout_ms, int events)
event.fd = fd;
event.events = 0;

if (timeout_ms < 0)
{
timeout_ms = -1;
}

if (events & SW_EVENT_READ)
{
event.events |= POLLIN;
Expand Down
17 changes: 17 additions & 0 deletions src/network/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,13 @@ static int swClient_tcp_recv_no_buffer(swClient *cli, char *data, int len, int f

while (1)
{
#ifdef HAVE_KQUEUE
int timeout_ms = (int) (cli->timeout * 1000);
if (swSocket_wait(cli->socket->fd, timeout_ms, SW_EVENT_READ) < 0)
{
return -1;
}
#endif
ret = swConnection_recv(cli->socket, data, len, flag);
if (ret >= 0)
{
Expand Down Expand Up @@ -990,6 +997,16 @@ static int swClient_udp_send(swClient *cli, const char *data, int len, int flags

static int swClient_udp_recv(swClient *cli, char *data, int length, int flags)
{
#ifdef HAVE_KQUEUE
if (!cli->async)
{
int timeout_ms = (int) (cli->timeout * 1000);
if (swSocket_wait(cli->socket->fd, timeout_ms, SW_EVENT_READ) < 0)
{
return -1;
}
}
#endif
cli->remote_addr.len = sizeof(cli->remote_addr.addr);
int ret = recvfrom(cli->socket->fd, data, length, flags, (struct sockaddr *) &cli->remote_addr.addr, &cli->remote_addr.len);
if (ret < 0)
Expand Down
1 change: 1 addition & 0 deletions src/protocol/mime_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static unordered_map<string, string> mime_map({
{ "jar", "application/java-archive" },
{ "war", "application/java-archive" },
{ "ear", "application/java-archive" },
{ "apk", "application/vnd.android.package-archive" },
{ "ser", "application/java-serialized-object" },
{ "class", "application/java-vm" },
{ "js", "application/javascript" },
Expand Down

0 comments on commit 91a9e03

Please sign in to comment.