Commit 45233543 authored by Andrew Price's avatar Andrew Price

Consider the wholist a requirement of a successful login

parent ca54bacf
Pipeline #681 passed with stage
in 9 minutes and 16 seconds
......@@ -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();
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment