summaryrefslogtreecommitdiffstats
path: root/src/libnfc_reader.c
diff options
context:
space:
mode:
authorLoïc Collignon <loic.collignon@iot.bzh>2017-11-09 15:03:18 +0100
committerLoïc Collignon <loic.collignon@iot.bzh>2017-11-09 15:03:18 +0100
commitaa5da1e1a47c4d8c6e3265e0d99335bebb28e378 (patch)
treecd4795cdb908874bd8cad1f821ff084b7832389e /src/libnfc_reader.c
parent2f540d4b238b773ee1eaf4aae4c08e2fb93cabc5 (diff)
rename verbs to match the aia-binding expectations.
Change-Id: Ic959f94f55cd3c010663369c54e63089725a8556 Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
Diffstat (limited to 'src/libnfc_reader.c')
-rw-r--r--src/libnfc_reader.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/libnfc_reader.c b/src/libnfc_reader.c
index a5d5430..ca9ee9b 100644
--- a/src/libnfc_reader.c
+++ b/src/libnfc_reader.c
@@ -261,23 +261,28 @@ void* libnfc_reader_main(void* arg)
return NULL;
}
-void sigterm_handler(int sig)
+void exit_handler()
{
size_t i;
nfc_device* dev;
- if (sig == SIGTERM && libnfc.context && libnfc.devices_count)
+ for(i = 0; i < libnfc.devices_count; ++i)
{
- for(i = 0; i < libnfc.devices_count; ++i)
+ if (libnfc.devices[i].device)
{
- if (libnfc.devices[i].device)
- {
- dev = libnfc.devices[i].device;
- libnfc.devices[i].device = NULL;
- nfc_close(dev);
- }
+ dev = libnfc.devices[i].device;
+ libnfc.devices[i].device = NULL;
+ nfc_close(dev);
}
- nfc_exit(libnfc.context);
- libnfc.context = NULL;
+ }
+ nfc_exit(libnfc.context);
+ libnfc.context = NULL;
+}
+
+void sigterm_handler(int sig)
+{
+ if (sig == SIGTERM && libnfc.context && libnfc.devices_count)
+ {
+ exit_handler();
}
}
@@ -293,6 +298,7 @@ int libnfc_init()
size_t ref_device_count;
size_t device_idx;
+ atexit(exit_handler);
memset(&libnfc, 0, sizeof(libnfc_context));