Commit 649e059f authored by Robert Schmidt's avatar Robert Schmidt

RFsim: Mark FD non-blocking once; show errno on problem

parent 7e82f2f4
......@@ -225,15 +225,16 @@ enum blocking_t {
};
static void setblocking(int sock, enum blocking_t active) {
int opts;
AssertFatal( (opts = fcntl(sock, F_GETFL)) >= 0,"");
int opts = fcntl(sock, F_GETFL);
AssertFatal(opts >= 0, "fcntl(): errno %d, %s\n", errno, strerror(errno));
if (active==blocking)
opts = opts & ~O_NONBLOCK;
else
opts = opts | O_NONBLOCK;
AssertFatal(fcntl(sock, F_SETFL, opts) >= 0, "");
opts = fcntl(sock, F_SETFL, opts);
AssertFatal(opts >= 0, "fcntl(): errno %d, %s\n", errno, strerror(errno));
}
static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps);
......@@ -248,7 +249,6 @@ static void fullwrite(int fd, void *_buf, ssize_t count, rfsimulator_state_t *t)
"Bug: %d/%p/%zd/%p", fd, _buf, count, t);
char *buf = _buf;
ssize_t l;
setblocking(fd, notBlocking);
while (count) {
l = write(fd, buf, count);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment