frames = snd_pcm_writei(pad->handle, data, frames);
if (frames == 0 || frames == -EAGAIN) {
char buf[100];
- if (pad->poll_fd >= 0 && FD_ISSET(pad->poll_fd, &s->rfds))
+ if (pad->poll_fd >= 0 && sched_read_ok(pad->poll_fd, s))
if (read(pad->poll_fd, buf, 100))
do_nothing;
return 0;
if (ret < 0)
goto out;
- if (!FD_ISSET(at->fd, &s->rfds))
+ if (!sched_read_ok(at->fd, s))
return 0;
bufsize = PARA_MAX(1024U, OPT_UINT32_VAL(BUFSIZE));
buf = para_malloc(bufsize);
* 0.8.0 we no longer need to request the feature.
*/
bool has_sha256;
- if (!FD_ISSET(ct->scc.fd, &s->wfds))
+ if (!sched_write_ok(ct->scc.fd, s))
return 0;
has_sha256 = has_feature("sha256", ct);
sprintf(buf, AUTH_REQUEST_MSG "%s%s", ct->user, has_sha256?
}
case CL_RECEIVED_PROCEED: /* concat args and send command */
{
- if (!FD_ISSET(ct->scc.fd, &s->wfds))
+ if (!sched_write_ok(ct->scc.fd, s))
return 0;
ret = send_sb_command(ct);
if (ret <= 0)
}
if (ret < 0)
goto close1;
- if (ret > 0 && FD_ISSET(ct->scc.fd, &s->wfds)) {
+ if (ret > 0 && sched_write_ok(ct->scc.fd, s)) {
sz = btr_next_buffer(ct->btrn[1], &buf2);
assert(sz);
ret = send_sb(ct, 1, buf2, sz, SBD_BLOB_DATA, true);
ret = btr_node_status(ct->btrn[0], 0, BTR_NT_ROOT);
if (ret < 0)
goto close0;
- if (ret > 0 && FD_ISSET(ct->scc.fd, &s->rfds)) {
+ if (ret > 0 && sched_read_ok(ct->scc.fd, s)) {
struct sb_buffer sbb;
ret = recv_sb(ct, &sbb);
if (ret < 0)
ret = prepare_output_file(wn);
goto out;
}
- if (!FD_ISSET(pfwd->fd, &s->wfds))
+ if (!sched_write_ok(pfwd->fd, s))
return 0;
bytes = btr_next_buffer(btrn, &buf);
assert(bytes > 0);
return 0;
if (phd->status == HTTP_CONNECTED) {
char *rq;
- if (!FD_ISSET(rn->fd, &s->wfds))
+ if (!sched_write_ok(rn->fd, s))
return 0;
rq = make_request_msg();
PARA_INFO_LOG("sending http request\n");
goto out;
}
ret = 0;
- if (!FD_ISSET(powd->fd, &s->wfds))
+ if (!sched_write_ok(powd->fd, s))
goto out;
/* get maximal number of bytes that can be written */
ret = ioctl(powd->fd, SNDCTL_DSP_GETOSPACE, &abi);
{
char c;
- if (!FD_ISSET(STDIN_FILENO, &s->rfds))
+ if (!sched_read_ok(STDIN_FILENO, s))
return 0;
if (read(STDIN_FILENO, &c, 1))
do_nothing;
void sched_request_timeout_ms(long unsigned ms, struct sched *s);
int sched_request_barrier(struct timeval *barrier, struct sched *s);
int sched_request_barrier_or_min_delay(struct timeval *barrier, struct sched *s);
+
+static inline bool sched_read_ok(int fd, const struct sched *s)
+{
+ return FD_ISSET(fd, &s->rfds);
+}
+
+static inline bool sched_write_ok(int fd, const struct sched *s)
+{
+ return FD_ISSET(fd, &s->wfds);
+}
goto out;
if (ret == 0)
return 0;
- if (!FD_ISSET(STDOUT_FILENO, &s->wfds))
+ if (!sched_write_ok(STDOUT_FILENO, s))
return 0;
if (sot->must_set_nonblock_flag) {
}
ctx->ping_sent = true;
}
- if (FD_ISSET(ctx->listen_fd, &s->rfds)) {
+ if (sched_read_ok(ctx->listen_fd, s)) {
char c;
for (;;) {
struct sockaddr src_addr;
#define MAP_POPULATE 0
#endif
-static void recv_afs_result(struct vss_task *vsst, fd_set *rfds)
+static void recv_afs_result(struct vss_task *vsst, const struct sched *s)
{
int ret, passed_fd, shmid;
uint32_t afs_code = 0, afs_data = 0;
struct stat statbuf;
- if (!FD_ISSET(vsst->afs_socket, rfds))
+ if (!sched_read_ok(vsst->afs_socket, s))
return;
ret = recv_afs_msg(vsst->afs_socket, &passed_fd, &afs_code, &afs_data);
if (ret == -ERRNO_TO_PARA_ERROR(EAGAIN))
mmd->sender_cmd_data.cmd_num = -1;
}
if (vsst->afsss != AFS_SOCKET_CHECK_FOR_WRITE)
- recv_afs_result(vsst, &s->rfds);
- else if (FD_ISSET(vsst->afs_socket, &s->wfds)) {
+ recv_afs_result(vsst, s);
+ else if (sched_write_ok(vsst->afs_socket, s)) {
PARA_INFO_LOG("requesting new fd from afs\n");
ret = write_buffer(vsst->afs_socket, "new");
if (ret < 0)