Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Update nailgun client
Browse files Browse the repository at this point in the history
Summary: This picks up facebookarchive/nailgun#57 and facebookarchive/nailgun#58 to actually close #262.

Test Plan: CI
  • Loading branch information
sdwilsh committed Jun 15, 2015
1 parent 1c7c03d commit e6ed02c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions third-party/nailgun/nailgun-client/ng.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>

#define NAILGUN_VERSION "0.9.0"

Expand All @@ -56,6 +57,12 @@
typedef unsigned int SOCKET;
#endif

#ifdef __APPLE__
#define SEND_FLAGS 0
#else
#define SEND_FLAGS MSG_NOSIGNAL
#endif

This comment has been minimized.

Copy link
@denji

denji Jul 13, 2015

// MSG_NOSIGNAL does not exists on OS X
#if defined(__APPLE__) || defined(__MACH__)
# ifndef MSG_NOSIGNAL
#   define MSG_NOSIGNAL SO_NOSIGPIPE
# endif
#endif

This comment has been minimized.

Copy link
@sdwilsh

sdwilsh Jul 13, 2015

Author Contributor

Please make that pull request upstream and we'd be happy to update nailgun here.


#ifndef MIN
#define MIN(a,b) ((a<b)?(a):(b))
#endif
Expand Down Expand Up @@ -191,9 +198,9 @@ int sendAll(SOCKET s, char *buf, int len) {
int total = 0;
int bytesleft = len;
int n = 0;

while(total < len) {
n = send(s, buf+total, bytesleft, 0);
n = send(s, buf+total, bytesleft, SEND_FLAGS);

This comment has been minimized.

Copy link
@denji

denji Jul 13, 2015

- n = send(s, buf+total, bytesleft, 0);
+ n = send(s, buf+total, bytesleft, MSG_NOSIGNAL);

if (n == -1) {
break;
Expand Down Expand Up @@ -235,7 +242,7 @@ void sendChunk(unsigned int size, char chunkType, char* buf) {
bytesSent = sendAll(nailgunsocket, header, CHUNK_HEADER_LEN);
if (bytesSent != 0 && size > 0) {
bytesSent = sendAll(nailgunsocket, buf, size);
} else if (bytesSent == 0) {
} else if (bytesSent == 0 && (chunkType != CHUNKTYPE_HEARTBEAT || errno != EPIPE)) {
perror("send");
handleSocketClose();
}
Expand Down

0 comments on commit e6ed02c

Please sign in to comment.