[mw-devel] [Git][milliways/mw][master] Consider the wholist a requirement of a successful login

Andrew Price welshbyte at sucs.org
Thu Jan 9 13:54:13 GMT 2020



Andrew Price pushed to branch master at milliways / mw


Commits:
45233543 by Andrew Price at 2020-01-09T13:49:06+00:00
Consider the wholist a requirement of a successful login

- - - - -


3 changed files:

- src/client/main.c
- src/client/who.c
- src/client/who.h


Changes:

=====================================
src/client/main.c
=====================================
@@ -669,9 +669,12 @@ int main(int argc, char **argv)
 	if (!autochat) printf(_("Type 'help' for help.\n"));
 	user->loggedin = time(0);
 
-	/* give the incoming pipe a chance to process before
-	 * we run the autoexec functions, so wholist etc can arrive */	
-	idle( -1, 1);
+	/* Server sends user list on login. */
+	/* Consider it a failure if we don't receive it within a generous interval. */
+	if (require_whoinfo()) {
+		fprintf(stderr, "Timed out waiting for server to send user list\n");
+		exit(1);
+	}
 
 	setup_js();
 


=====================================
src/client/who.c
=====================================
@@ -64,6 +64,22 @@ static int refresh_wholist(int type)
 	return 0;
 }
 
+/* If we don't get the who list within the timeout, fail */
+#define WHOINFO_TIMEOUT 10000
+#define WHOINFO_CHECK_INTERVAL (WHOINFO_TIMEOUT / 250)
+int require_whoinfo(void)
+{
+	int n = 0;
+
+	while (whoinfo == NULL && n < WHOINFO_TIMEOUT) {
+		idle(-1, WHOINFO_CHECK_INTERVAL);
+		n += WHOINFO_CHECK_INTERVAL;
+	}
+	if (whoinfo == NULL)
+		return 1;
+	return 0;
+}
+
 void display_wholist(int mode)
 {
 	time_t now = time(NULL);


=====================================
src/client/who.h
=====================================
@@ -8,6 +8,7 @@ void check_copies(int32_t where);
 char *itime(unsigned long t);
 void display_wholist(int type);
 void update_wholist(ipc_message_t *msg);
+int require_whoinfo(void);
 char *part_who_talk(const char *text, int status);
 char *part_who(const char *text, int status);
 json_t * grab_wholist(void);



View it on GitLab: https://projects.sucs.org/milliways/mw/commit/45233543aa2be8a2f66ff2588b65ff1af9ee118f

-- 
View it on GitLab: https://projects.sucs.org/milliways/mw/commit/45233543aa2be8a2f66ff2588b65ff1af9ee118f
You're receiving this email because of your account on projects.sucs.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20200109/ea186509/attachment-0001.html>


More information about the mw-devel mailing list