Add ability to recover somewhat from a dead master node

ulab-next-nosound
Timothy Pearson 13 years ago committed by Timothy Pearson
parent 3abfd23294
commit ce82d1f189

@ -103,6 +103,35 @@ char raptor_sm_deallocate_session(char* username) {
return 1; return 1;
} }
pid_t serverpid = raptor_sm_get_pid_for_username(username);
if (serverpid >= 0) {
// Verify existence of PID on remote server
dprint("Verifying process %d on %s...\n\r", serverpid, row[1]);
char* ip = raptor_sm_get_ip_for_hostname(row[1], 0);
char* command_string;
asprintf(&command_string, "ssh root@%s \'ps -p %d | grep %d\'", ip, serverpid, serverpid);
FILE *fp;
char output[1024];
// Open the command for reading
fp = popen(command_string, "r");
if (fp == NULL) {
mysql_close(conn);
return -1;
}
// Read the output a line at a time
fgets(output, sizeof(output)-1, fp);
// Close output
pclose(fp);
free(command_string);
free(ip);
dprint("...result was %s\n\r", output);
if (strcmp(output, "") != 0) {
mysql_free_result(res);
mysql_close(conn);
return 0;
}
}
// Remove the user from the system // Remove the user from the system
char* safe_username = get_mysql_escaped_string(conn, username); char* safe_username = get_mysql_escaped_string(conn, username);
asprintf(&query, "DELETE FROM sessions WHERE username='%s'", safe_username); asprintf(&query, "DELETE FROM sessions WHERE username='%s'", safe_username);

Loading…
Cancel
Save