void CtdlUnregisterProtoHook(void (*handler) (char *), char *cmd)
{
- struct ProtoFunctionHook *cur, *p;
+ struct ProtoFunctionHook *cur, *p, *lastcur;
- for (cur = ProtoHookList; cur != NULL; cur = cur->next) {
+ for (cur = ProtoHookList;
+ cur != NULL;
+ cur = (cur != NULL)? cur->next: NULL) {
/* This will also remove duplicates if any */
while (cur != NULL &&
handler == cur->handler &&
if (cur == ProtoHookList) {
ProtoHookList = p;
}
+ else if (lastcur != NULL)
+ {
+ lastcur->next = p;
+ }
free(cur);
cur = p;
}
+ lastcur = cur;
+ }
+}
+
+void CtdlDestroyProtoHooks(void)
+{
+ struct ProtoFunctionHook *cur, *p;
+
+ cur = ProtoHookList;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed server command %s (%s)\n",
+ cur->cmd, cur->desc);
+ p = cur->next;
+ free(cur);
+ cur = p;
}
+ ProtoHookList = NULL;
}
}
}
+void CtdlDestroyCleanupHooks(void)
+{
+ struct CleanupFunctionHook *cur, *p;
+
+ cur = CleanupHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed cleanup function\n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ CleanupHookTable = NULL;
+}
+
void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType)
{
}
}
+void CtdlDestroySessionHooks(void)
+{
+ struct SessionFunctionHook *cur, *p;
+
+ cur = SessionHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed session function\n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ SessionHookTable = NULL;
+}
+
void CtdlRegisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
{
}
}
+void CtdlDestroyUserHooks(void)
+{
+ struct UserFunctionHook *cur, *p;
+
+ cur = UserHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed user function \n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ UserHookTable = NULL;
+}
+
void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
int EventType)
}
}
+void CtdlDestroyMessageHook(void)
+{
+ struct MessageFunctionHook *cur, *p;
+
+ cur = MessageHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed message function \n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ MessageHookTable = NULL;
+}
+
void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
{
}
}
+void CtdlDestroyNetprocHooks(void)
+{
+ struct NetprocFunctionHook *cur, *p;
+
+ cur = NetprocHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Unregistered netproc function\n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ NetprocHookTable = NULL;
+}
+
void CtdlRegisterDeleteHook(void (*handler)(char *, long) )
{
}
}
}
+void CtdlDestroyDeleteHooks(void)
+{
+ struct DeleteFunctionHook *cur, *p;
+
+ cur = DeleteHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed netproc function\n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ DeleteHookTable = NULL;
+}
}
}
+void CtdlDestroyFixedOutputHooks(void)
+{
+ struct FixedOutputHook *cur, *p;
+
+ cur = FixedOutputTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed fixed output function for %s\n", cur->content_type);
+ p = cur->next;
+ free(cur);
+ cur = p;
+
+ }
+ FixedOutputTable = NULL;
+}
+
/* returns nonzero if we found a hook and used it */
int PerformFixedOutputHooks(char *content_type, char *content, int content_length)
{
}
}
+void CtdlDestroyXmsgHooks(void)
+{
+ struct XmsgFunctionHook *cur, *p;
+
+ cur = XmsgHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed x-msg function "
+ "(priority %d)\n", cur->order);
+ p = cur->next;
+
+ free(cur);
+ cur = p;
+ }
+ XmsgHookTable = NULL;
+}
+
void CtdlRegisterServiceHook(int tcp_port,
char *sockpath,
}
else if (tcp_port <= 0) { /* port -1 to disable */
lprintf(CTDL_INFO, "Service has been manually disabled, skipping\n");
+ free (message);
free(newfcn);
return;
}
AddPortError(message, error);
strcat(message, "FAILED.");
lprintf(CTDL_CRIT, "%s\n", message);
+ free (message);
free(error);
free(newfcn);
}
}
}
+void CtdlDestroyServiceHook(void)
+{
+ struct ServiceFunctionHook *cur, *p;
+
+ cur = ServiceHookTable;
+ while (cur != NULL)
+ {
+ close(cur->msock);
+ if (cur->sockpath) {
+ lprintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
+ cur->sockpath);
+ } else if (cur->tcp_port) {
+ lprintf(CTDL_INFO, "Closed TCP port %d\n", cur->tcp_port);
+ } else {
+ lprintf(CTDL_INFO, "Unregistered unknown service\n");
+ }
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ ServiceHookTable = NULL;
+}
+
void PerformSessionHooks(int EventType)
{
void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType);
void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
+void CtdlDestroySessionHooks(void);
void PerformSessionHooks(int EventType);
void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
+void CtdlDestroyUserHooks(void);
void PerformUserHooks(struct ctdluser *usbuf, int EventType);
void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *), int order);
void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *), int order);
int PerformXmsgHooks(char *, char *, char *);
+void CtdlDestroyXmsgHooks(void);
+
void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
int EventType);
void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
int EventType);
+void CtdlDestroyMessageHook(void);
int PerformMessageHooks(struct CtdlMessage *, int EventType);
void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
+void CtdlDestroyNetprocHooks(void);
int PerformNetprocHooks(struct CtdlMessage *, char *);
void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
void CtdlUnregisterDeleteHook(void (*handler)(char *, long) );
+void CtdlDestroyDeleteHooks(void);
void PerformDeleteHooks(char *, long);
void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void));
+void CtdlDestroyCleanupHooks(void);
void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
void CtdlUnregisterProtoHook(void (*handler)(char *), char *cmd);
+void CtdlDestroyProtoHooks(void);
void CtdlRegisterServiceHook(int tcp_port,
char *sockpath,
void (*h_greeting_function) (void),
void (*h_command_function) (void),
void (*h_async_function) (void)
);
+void CtdlDestroyServiceHook(void);
void CtdlRegisterFixedOutputHook(char *content_type,
void (*output_function) (char *supplied_data, int len)
);
void CtdlUnRegisterFixedOutputHook(char *content_type);
+void CtdlDestroyFixedOutputHooks(void);
int PerformFixedOutputHooks(char *, char *, int);
#endif /* SERV_EXTENSIONS_H */
int enable_syslog = 0;
extern int running_as_daemon;
+void DestroyWorkerList(void);
+
/*
* lprintf() ... Write logging information
*/
master_cleanup(signum);
}
-
/*
* Some initialization stuff...
*/
unlink(serviceptr->sockpath);
}
}
+#ifdef HAVE_OPENSSL
+ destruct_ssl();
+#endif
+ CtdlDestroyProtoHooks();
+ CtdlDestroyDeleteHooks();
+ CtdlDestroyXmsgHooks();
+ CtdlDestroyNetprocHooks();
+ CtdlDestroyUserHooks();
+ CtdlDestroyMessageHook();
+ CtdlDestroyCleanupHooks();
+ CtdlDestroyFixedOutputHooks();
+ CtdlDestroySessionHooks();
+ CtdlDestroyServiceHook();
+ DestroyWorkerList();
}
+
+
/*
* Terminate another session.
* (This could justifiably be moved out of sysdep.c because it
pthread_attr_destroy(&attr);
}
+void DestroyWorkerList(void)
+{
+ struct worker_node *cur, *p;
+ cur = worker_list;
+ while (cur != NULL)
+ {
+ p = cur->next;
+ free (cur);
+ cur = p;
+ }
+ worker_list = NULL;
+}
/*
* Create the indexer thread and begin its operation.
do_housekeeping();
check_sched_shutdown();
}
-
+ if (con != NULL) free (con);//// TODO: could this harm other threads?
/* If control reaches this point, the server is shutting down */
return(NULL);
}