All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit efff15e4 authored by Ryan Jackson's avatar Ryan Jackson

Modified all functions in libtmcd to be reentrant and thread-safe. Also a bit of general clean-up

parent 8ec627ba
This diff is collapsed.
......@@ -2,14 +2,35 @@
#define _LIBTMCD_H_
#include <netinet/in.h>
#include <mysql/mysql.h>
#include <arpa/inet.h>
#include "tbdefs.h"
#ifdef EVENTSYS
#include "event.h"
#endif
#define DBNAME_SIZE 64
#define HOSTID_SIZE (32+64)
/*
* This structure is passed to each request function. The intent is to
* reduce the number of DB queries per request to a minimum.
*/
typedef struct {
MYSQL db;
int db_connected;
char dbname[DBNAME_SIZE];
char prev_dbname[DBNAME_SIZE];
struct in_addr myipaddr;
#ifdef EVENTSYS
event_handle_t event_handle;
#endif
char fshostid[HOSTID_SIZE];
int verbose;
int debug;
int isssl;
int istcp;
int version;
struct in_addr client;
int allocated;
......@@ -17,8 +38,6 @@ typedef struct {
int isvnode;
int issubnode;
int islocal;
int isssl;
int istcp;
int iscontrol;
int isplabdslice;
int isplabsvc;
......@@ -51,12 +70,11 @@ typedef struct {
int length;
} tmcdresp_t;
int iptonodeid(struct in_addr, tmcdreq_t *);
int nodeidtoexp(char *nodeid, char *pid, char *eid, char *gid);
int checkprivkey(struct in_addr, char *);
int iptonodeid(tmcdreq_t *, struct in_addr);
int checkprivkey(tmcdreq_t *reqp, struct in_addr, char *);
int checkdbredirect(tmcdreq_t *);
void tmcd_free_response(tmcdresp_t *);
tmcdresp_t *tmcd_handle_request(int, char *, char *, tmcdreq_t *);
int tmcd_init(char *, struct in_addr *, int, int);
tmcdresp_t *tmcd_handle_request(tmcdreq_t *, int, char *, char *);
int tmcd_init(tmcdreq_t *reqp, struct in_addr *, char *);
#endif /* _LIBTMCD_H_ */
......@@ -780,12 +780,15 @@ handle_request(int sock, struct sockaddr_in *client, char *rdata, int istcp)
}
}
tmcd_init(NULL, &myipaddr, verbose, debug);
reqp->verbose = verbose;
reqp->debug = debug;
tmcd_init(reqp, &myipaddr, NULL);
/*
* Map the ip to a nodeid.
*/
if ((err = iptonodeid(client->sin_addr, reqp))) {
if ((err = iptonodeid(reqp, client->sin_addr))) {
if (reqp->isvnode) {
error("No such vnode %s associated with %s\n",
reqp->vnodeid, inet_ntoa(client->sin_addr));
......@@ -826,13 +829,21 @@ handle_request(int sock, struct sockaddr_in *client, char *rdata, int istcp)
/*
* If the connection is not SSL, then it must be a local node.
*/
if (reqp->isssl) {
if (isssl) {
#if 0
if (tmcd_sslverify_client(reqp->nodeid, reqp->pclass,
reqp->ptype, reqp->islocal)) {
error("%s: SSL verification failure\n", reqp->nodeid);
if (! redirect)
goto skipit;
}
#endif
if (tmcd_sslverify_client(NULL, NULL,
reqp->ptype, reqp->islocal)) {
error("%s: SSL verification failure\n", reqp->nodeid);
if (! redirect)
goto skipit;
}
}
else if (reqp->iscontrol) {
error("%s: Control node connection without SSL!\n",
......@@ -881,14 +892,14 @@ handle_request(int sock, struct sockaddr_in *client, char *rdata, int istcp)
goto skipit;
*/
}
else if (checkprivkey(client->sin_addr, privkey)) {
else if (checkprivkey(reqp, client->sin_addr, privkey)) {
error("%s: privkey mismatch: %s!\n",
reqp->nodeid, privkey);
goto skipit;
}
}
execute:
response = tmcd_handle_request(sock, bp, rdata, reqp);
response = tmcd_handle_request(reqp, sock, bp, rdata);
skipit:
if (response) {
......
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