toolbox

Check-in [90f21a92ca]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:radios-check: remove superfluous polling
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:90f21a92cad4099b0ef6853866765e95f08761f8bcbe89ed734613fc932f9d7d
User & Date: jef 2019-04-16 12:26:15
Context
2019-04-17
08:56
radios-check: simplify job data structure check-in: f049f8915e user: jef tags: trunk
2019-04-16
12:26
radios-check: remove superfluous polling check-in: 90f21a92ca user: jef tags: trunk
2019-04-15
20:36
radios-check: fix memmove index check-in: e75c5886d3 user: jef tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/radios-check/radios-check.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#include <poll.h>
#include <curl/curl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/queue.h>
#include "cJSON.h"
#include "die.h"
#include "xmalloc.h"
................................................................................
void
job_wait(struct job *jobs, size_t size)
{
	size_t i;
	int status;
	pid_t pid;
	struct job job;
	struct pollfd fd[1];

	pid = waitpid(-1, &status, 0);
	for (i = 0; jobs[i].pid != pid; i++);
	job = jobs[i];
	fd[0].fd = job.fd;
	fd[0].events = POLLIN;
	if (poll(fd, 1, 0) > 0) {
		if (read(job.fd, &job.res, sizeof(job.res)) == sizeof(job.res))
			job.res.radio->ok = job.res.ok;
	}
	close(job.fd);
	memmove(jobs + i, jobs + i + 1, (size - i - 1) * sizeof(struct job));
}

void
radios_pcheck(struct radios *radios)
{





<







 







<




<
<
<
|
|
<







1
2
3
4
5

6
7
8
9
10
11
12
...
225
226
227
228
229
230
231

232
233
234
235



236
237

238
239
240
241
242
243
244
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>

#include <curl/curl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/queue.h>
#include "cJSON.h"
#include "die.h"
#include "xmalloc.h"
................................................................................
void
job_wait(struct job *jobs, size_t size)
{
	size_t i;
	int status;
	pid_t pid;
	struct job job;


	pid = waitpid(-1, &status, 0);
	for (i = 0; jobs[i].pid != pid; i++);
	job = jobs[i];



	if (read(job.fd, &job.res, sizeof(job.res)) == sizeof(job.res))
		job.res.radio->ok = job.res.ok;

	close(job.fd);
	memmove(jobs + i, jobs + i + 1, (size - i - 1) * sizeof(struct job));
}

void
radios_pcheck(struct radios *radios)
{