summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-03 13:25:12 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-03 13:25:12 +0200
commit44b55f0b03ffc6aff4f1c290b5687d5ac95ddbf9 (patch)
tree6e80ca15368a75908ba4053ceb07c25269ae786c /src/lib/dev.c
parentd409fd569683d8f0e8c8f65d4820087dbf7c0786 (diff)
parentca494922f3815077efbcd28da3748df38c8a6961 (diff)
downloadouroboros-44b55f0b03ffc6aff4f1c290b5687d5ac95ddbf9.tar.gz
ouroboros-44b55f0b03ffc6aff4f1c290b5687d5ac95ddbf9.zip
Merged in dstaesse/ouroboros/be-select (pull request #184)
select() like call
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index f13c8423..22e77169 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -130,17 +130,14 @@ void ap_fini(void)
free(_ap_instance);
}
-#if 0
static int port_id_to_fd(int port_id)
{
int i;
for (i = 0; i < AP_MAX_FLOWS; ++i)
- if (_ap_instance->flows[i].port_id == port_id
- && _ap_instance->flows[i].state != FLOW_NULL)
+ if (_ap_instance->flows[i].port_id == port_id)
return i;
return -1;
}
-#endif
int flow_accept(char ** ae_name)
{
@@ -523,6 +520,14 @@ ssize_t flow_write(int fd, void * buf, size_t count)
return 0;
}
+int flow_select(const struct timespec * timeout)
+{
+ int port_id = shm_ap_rbuff_peek(_ap_instance->rb, timeout);
+ if (port_id < 0)
+ return port_id;
+ return port_id_to_fd(port_id);
+}
+
ssize_t flow_read(int fd, void * buf, size_t count)
{
int idx = -1;