changeset 86:310a6abb7454

capture: start the iothread before we write to the device Even though the iothread doesn't handle writes to the device, it does all the reading. Which means that it is the place that will see the command acks and will (eventually) notify the waiting writers. In order to do that, the iothread must start first. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Mon, 22 Feb 2021 07:56:56 -0500
parents a4689cefafeb
children 0e4ab6c2a99c
files capture.c
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/capture.c	Fri Apr 10 23:05:50 2020 -0400
+++ b/capture.c	Mon Feb 22 07:56:56 2021 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2019-2021 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -359,19 +359,20 @@
 	if (setvbuf(ifile, file_buffer, _IOFBF, sizeof(file_buffer)) == EOF)
 		fprintf(stderr, "Warn: Failed to mark stream as buffered\n");
 
+	/* start the iothread before we make any writes to the device */
+	ret = iothread_start(ifile, rfile, verbose, !input_readonly);
+	if (ret) {
+		fprintf(stderr, "Error: Failed to spawn I/O thread: %s\n",
+			xstrerror(ret));
+		return 10;
+	}
+
 	ret = cfg_port(ifile, input_readonly, ubxport, enable_beidou,
 		       enable_galileo, enable_gps, enable_glonass,
 		       enable_sbas);
 	if (ret) {
 		fprintf(stderr, "Error: Failed to configure port: %s\n",
 			xstrerror(ret));
-		return 10;
-	}
-
-	ret = iothread_start(ifile, rfile, verbose, !input_readonly);
-	if (ret) {
-		fprintf(stderr, "Error: Failed to spawn I/O thread: %s\n",
-			xstrerror(ret));
 		return 11;
 	}