summaryrefslogtreecommitdiff
path: root/patlooptest.c
diff options
context:
space:
mode:
authorRuss Meyerriecks <rmeyerreicks@digium.com>2011-07-21 17:29:34 +0000
committerRuss Meyerriecks <rmeyerreicks@digium.com>2011-07-21 17:29:34 +0000
commit690e01f23fbf4b83977bc4cf89a51c8807e6dc68 (patch)
tree0e36deda3ba86ea88dbc7401e28cd6258ae5a05e /patlooptest.c
parentdf3a9f880353c2fcfd56c0543158ebe00a4bd11f (diff)
patlooptest: Ignore the first buffered event
Fixes the feature introduced in r9909 that allows patlooptest to monitor channel events. Patlooptest was reporting events that we don't care about, prior to reading from the channel. This fix ignore the first event read on a channel and reports all subsequent events properly. Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@10071 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'patlooptest.c')
-rw-r--r--patlooptest.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/patlooptest.c b/patlooptest.c
index f003ae1..7563bfe 100644
--- a/patlooptest.c
+++ b/patlooptest.c
@@ -167,6 +167,7 @@ int main(int argc, char *argv[])
char * device;
int opt;
int oldstyle_cmdline = 1;
+ unsigned int event_count = 0;
/* Parse the command line arguments */
while((opt = getopt(argc, argv, "b:s:t:r:v?h")) != -1) {
@@ -248,9 +249,14 @@ int main(int argc, char *argv[])
write_again:
res = write(fd,outbuf,bs);
if (res != bs) {
- printf("W: Res is %d: %s\n", res, strerror(errno));
- ioctl(fd, DAHDI_GETEVENT, &x);
- printf("Event: %d\n", x);
+ if (ELAST == errno) {
+ ioctl(fd, DAHDI_GETEVENT, &x);
+ if (event_count > 0)
+ printf("Event: %d\n", x);
+ ++event_count;
+ } else {
+ printf("W: Res is %d: %s\n", res, strerror(errno));
+ }
goto write_again;
}