Commit 45233543 authored by Andrew Price's avatar Andrew Price
Browse files

Consider the wholist a requirement of a successful login

parent ca54bacf
Loading
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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();

+16 −0
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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);