}
}
- printf("IN FORK!\n");
retval = plibc_func();
if(retval == 0)
void ust_fork(void)
{
+ struct blocked_consumer *bc;
+ struct blocked_consumer *deletable_bc = NULL;
+ int result;
+
DBG("ust: forking");
ltt_trace_stop("auto");
ltt_trace_destroy("auto");
- ltt_trace_alloc("auto");
- ltt_trace_start("auto");
- init_socket();
+ /* Delete all active connections */
+ ustcomm_close_all_connections(&ustcomm_app.server);
+
+ /* Delete all blocked consumers */
+ list_for_each_entry(bc, &blocked_consumers, list) {
+ free(deletable_bc);
+ deletable_bc = bc;
+ list_del(&bc->list);
+ }
+
have_listener = 0;
create_listener();
+ init_socket();
+ ltt_trace_setup("auto");
+ result = ltt_trace_set_type("auto", "ustrelay");
+ if(result < 0) {
+ ERR("ltt_trace_set_type failed");
+ return (void *)1;
+ }
+
+ ltt_trace_alloc("auto");
+ ltt_trace_start("auto");
inform_consumer_daemon("auto");
}
//ust// }
/* Must be called while sure that trace is in the list. */
-static int _ltt_trace_destroy(struct ltt_trace_struct *trace)
+static int _ltt_trace_destroy(struct ltt_trace_struct *trace)
{
int err = -EPERM;
return 0;
}
+/* Called after a fork. */
+
+int ustcomm_close_all_connections(struct ustcomm_server *server)
+{
+ struct ustcomm_connection *conn;
+ struct ustcomm_connection *deletable_conn = NULL;
+
+ list_for_each_entry(conn, &server->connections, list) {
+ free(deletable_conn);
+ deletable_conn = conn;
+ close(conn->fd);
+ list_del(&conn->list);
+ }
+
+ return 0;
+}
+
/* @timeout: max blocking time in milliseconds, -1 means infinity
*
* returns 1 to indicate a message was received
extern int ustcomm_send_request(struct ustcomm_connection *conn, const char *req, char **reply);
extern int ustcomm_send_reply(struct ustcomm_server *server, char *msg, struct ustcomm_source *src);
extern int ustcomm_disconnect(struct ustcomm_connection *conn);
+extern int ustcomm_close_all_connections(struct ustcomm_server *server);
extern int nth_token_is(char *str, char *token, int tok_no);