Browse Source

Bugfix: Since we are using pipes for select notifier on *nix, we need to use read/write there

Luke Dashjr 13 years ago
parent
commit
7ed01d4d5b
3 changed files with 16 additions and 2 deletions
  1. 1 2
      miner.c
  2. 14 0
      util.c
  3. 1 0
      util.h

+ 1 - 2
miner.c

@@ -3700,8 +3700,7 @@ static void *submit_work_thread(__maybe_unused void *userdata)
 		total_submitting -= tsreduce;
 		tsreduce = 0;
 		if (FD_ISSET(submit_waiting_notifier[0], &rfds)) {
-			char buf[0x10];
-			(void)recv(submit_waiting_notifier[0], buf, sizeof(buf), 0);
+			notifier_read(submit_waiting_notifier);
 		}
 		while (!list_empty(&submit_waiting)) {
 			struct work *work = list_entry(submit_waiting.next, struct work, list);

+ 14 - 0
util.c

@@ -1633,5 +1633,19 @@ void notifier_init(int pipefd[2])
 
 void notifier_wake(int fd[2])
 {
+#ifdef WIN32
 	(void)send(fd[1], "\0", 1, 0);
+#else
+	(void)write(fd[1], "\0", 1);
+#endif
+}
+
+void notifier_read(int fd[2])
+{
+	char buf[0x10];
+#ifdef WIN32
+	(void)recv(fd[0], buf, sizeof(buf), 0);
+#else
+	(void)read(fd[0], buf, sizeof(buf));
+#endif
 }

+ 1 - 0
util.h

@@ -71,5 +71,6 @@ void RenameThread(const char* name);
 
 extern void notifier_init(int pipefd[2]);
 extern void notifier_wake(int fd[2]);
+extern void notifier_read(int fd[2]);
 
 #endif /* __UTIL_H__ */