Browse Source

Bugfix: Winsock needs send/recv for sockets, not write/read

Send wrapped in new notifier_wake function
Luke Dashjr 13 years ago
parent
commit
28106b125c
3 changed files with 10 additions and 3 deletions
  1. 3 3
      miner.c
  2. 5 0
      util.c
  3. 2 0
      util.h

+ 3 - 3
miner.c

@@ -3083,7 +3083,7 @@ static void __kill_work(void)
 	shutting_down = true;
 
 	applog(LOG_DEBUG, "Prompting submit_work thread to finish");
-	(void)write(submit_waiting_notifier[1], "\0", 1);
+	notifier_wake(submit_waiting_notifier);
 
 	applog(LOG_DEBUG, "Killing off watchpool thread");
 	/* Kill the watchpool thread */
@@ -3701,7 +3701,7 @@ static void *submit_work_thread(__maybe_unused void *userdata)
 		tsreduce = 0;
 		if (FD_ISSET(submit_waiting_notifier[0], &rfds)) {
 			char buf[0x10];
-			(void)read(submit_waiting_notifier[0], buf, sizeof(buf));
+			(void)recv(submit_waiting_notifier[0], buf, sizeof(buf), 0);
 		}
 		while (!list_empty(&submit_waiting)) {
 			struct work *work = list_entry(submit_waiting.next, struct work, list);
@@ -6099,7 +6099,7 @@ void submit_work_async(struct work *work_in, struct timeval *tv_work_found)
 	list_add_tail(&work->list, &submit_waiting);
 	mutex_unlock(&submitting_lock);
 
-	(void)write(submit_waiting_notifier[1], "\0", 1);
+	notifier_wake(submit_waiting_notifier);
 }
 
 enum test_nonce2_result hashtest2(struct work *work, bool checktarget)

+ 5 - 0
util.c

@@ -1630,3 +1630,8 @@ void notifier_init(int pipefd[2])
 		quit(1, "Failed to create pipe in create_notifier");
 #endif
 }
+
+void notifier_wake(int fd[2])
+{
+	(void)send(fd[1], "\0", 1, 0);
+}

+ 2 - 0
util.h

@@ -68,6 +68,8 @@ void suspend_stratum(struct pool *pool);
 void dev_error(struct cgpu_info *dev, enum dev_reason reason);
 void *realloc_strcat(char *ptr, char *s);
 void RenameThread(const char* name);
+
 extern void notifier_init(int pipefd[2]);
+extern void notifier_wake(int fd[2]);
 
 #endif /* __UTIL_H__ */