Lines Matching defs:fifos

206  * @fifos
213 static int _daemon_read(struct dm_event_fifos *fifos,
228 FD_SET(fifos->server, &fds);
230 ret = select(fifos->server + 1, &fds, NULL, NULL,
242 ret = read(fifos->server, buf + bytes, size);
273 static int _daemon_write(struct dm_event_fifos *fifos,
292 FD_SET(fifos->server, &fds);
294 ret = select(fifos->server + 1, &fds, NULL, NULL, &tval);
301 read(fifos->server, drainbuf, 127);
308 FD_SET(fifos->client, &fds);
309 ret = select(fifos->client + 1, NULL, &fds, NULL, NULL);
316 ret = write(fifos->client, ((char *) buf) + bytes,
333 static int _daemon_talk(struct dm_event_fifos *fifos,
362 if (!_daemon_write(fifos, msg)) {
375 if (!_daemon_read(fifos, msg)) {
390 * the events. I am currently test opening one of the fifos to
398 static int _start_daemon(struct dm_event_fifos *fifos)
404 if (stat(fifos->client_path, &statbuf))
408 log_error("%s is not a fifo.", fifos->client_path);
413 fifos->client = open(fifos->client_path, O_WRONLY | O_NONBLOCK);
414 if (fifos->client >= 0) {
417 close(fifos->client);
423 __func__, fifos->client_path, strerror(errno));
458 static int _init_client(struct dm_event_fifos *fifos)
463 /* init fifos */
464 memset(fifos, 0, sizeof(*fifos));
465 fifos->client_path = DM_EVENT_FIFO_CLIENT;
466 fifos->server_path = DM_EVENT_FIFO_SERVER;
468 if (!_start_daemon(fifos)) {
474 if ((fifos->server = open(fifos->server_path, O_RDWR)) < 0) {
476 __func__, fifos->server_path);
482 if (flock(fifos->server, LOCK_EX) < 0) {
483 log_error("%s: flock %s", __func__, fifos->server_path);
484 close(fifos->server);
488 /* if ((fifos->client = open(fifos->client_path, O_WRONLY | O_NONBLOCK)) < 0) {*/
489 if ((fifos->client = open(fifos->client_path, O_RDWR | O_NONBLOCK)) < 0) {
491 __func__, fifos->client_path, strerror(errno));
492 close(fifos->server);
500 static void _dtr_client(struct dm_event_fifos *fifos)
502 if (flock(fifos->server, LOCK_UN))
503 log_error("flock unlock %s", fifos->server_path);
505 close(fifos->client);
506 close(fifos->server);
558 struct dm_event_fifos fifos;
560 if (!_init_client(&fifos)) {
565 ret = _daemon_talk(&fifos, msg, DM_EVENT_CMD_HELLO, 0, 0, 0, 0);
572 ret = _daemon_talk(&fifos, msg, cmd, dso_name, dev_name, evmask, timeout);
575 _dtr_client(&fifos);