good for merge On Thu, 2010-02-25 at 19:29 +1100, Angus Salkeld wrote: > This just to convert non thread safe calls to thread safe ones. > > -Angus > > Signed-off-by: Angus Salkeld <[email protected]> > --- > exec/coroipcs.c | 17 +++++++++++++---- > exec/coroparse.c | 4 +++- > exec/logsys.c | 4 +++- > exec/main.c | 16 +++++++++++++--- > exec/totemconfig.c | 7 +++++-- > exec/totemsrp.c | 12 +++++++++--- > exec/totemudp.c | 27 ++++++++++++++++++++------- > lcr/uis.c | 4 +++- > 8 files changed, 69 insertions(+), 22 deletions(-) > > diff --git a/exec/coroipcs.c b/exec/coroipcs.c > index d380dad..546b800 100644 > --- a/exec/coroipcs.c > +++ b/exec/coroipcs.c > @@ -985,6 +985,7 @@ static void _corosync_ipc_init(void) > int server_fd; > struct sockaddr_un un_addr; > int res; > + > /* > * Create socket for IPC clients, name socket, listen for connections > */ > @@ -1000,7 +1001,9 @@ static void _corosync_ipc_init(void) > > res = fcntl (server_fd, F_SETFL, O_NONBLOCK); > if (res == -1) { > - log_printf (LOGSYS_LEVEL_CRIT, "Could not set non-blocking > operation on server socket: %s\n", strerror (errno)); > + char error_str[100]; > + strerror_r (errno, error_str, 100); > + log_printf (LOGSYS_LEVEL_CRIT, "Could not set non-blocking > operation on server socket: %s\n", error_str); > api->fatal_error ("Could not set non-blocking operation on > server socket"); > } > > @@ -1027,7 +1030,9 @@ static void _corosync_ipc_init(void) > > res = bind (server_fd, (struct sockaddr *)&un_addr, > COROSYNC_SUN_LEN(&un_addr)); > if (res) { > - log_printf (LOGSYS_LEVEL_CRIT, "Could not bind AF_UNIX (%s): > %s.\n", un_addr.sun_path, strerror (errno)); > + char error_str[100]; > + strerror_r (errno, error_str, 100); > + log_printf (LOGSYS_LEVEL_CRIT, "Could not bind AF_UNIX (%s): > %s.\n", un_addr.sun_path, error_str); > api->fatal_error ("Could not bind to AF_UNIX socket\n"); > } > > @@ -1521,16 +1526,20 @@ retry_accept: > } > > if (new_fd == -1) { > + char error_str[100]; > + strerror_r (errno, error_str, 100); > log_printf (LOGSYS_LEVEL_ERROR, > - "Could not accept Library connection: %s\n", strerror > (errno)); > + "Could not accept Library connection: %s\n", error_str); > return (0); /* This is an error, but -1 would indicate > disconnect from poll loop */ > } > > res = fcntl (new_fd, F_SETFL, O_NONBLOCK); > if (res == -1) { > + char error_str[100]; > + strerror_r (errno, error_str, 100); > log_printf (LOGSYS_LEVEL_ERROR, > "Could not set non-blocking operation on library > connection: %s\n", > - strerror (errno)); > + error_str); > close (new_fd); > return (0); /* This is an error, but -1 would indicate > disconnect from poll loop */ > } > diff --git a/exec/coroparse.c b/exec/coroparse.c > index ab2ecb6..a1e3843 100644 > --- a/exec/coroparse.c > +++ b/exec/coroparse.c > @@ -379,9 +379,11 @@ static int read_config_file_into_objdb( > > fp = fopen (filename, "r"); > if (fp == NULL) { > + char error_str[100]; > + strerror_r (errno, error_str, 100); > snprintf (error_reason, sizeof(error_string_response), > "Can't read file %s reason = (%s)\n", > - filename, strerror (errno)); > + filename, error_str); > *error_string = error_reason; > return -1; > } > diff --git a/exec/logsys.c b/exec/logsys.c > index d43f983..39c7c0a 100644 > --- a/exec/logsys.c > +++ b/exec/logsys.c > @@ -943,12 +943,14 @@ static int logsys_config_file_set_unlocked ( > > logsys_loggers[subsysid].logfile_fp = fopen (file, "a+"); > if (logsys_loggers[subsysid].logfile_fp == NULL) { > + char error_str[100]; > + strerror_r (errno, error_str, 100); > free(logsys_loggers[subsysid].logfile); > logsys_loggers[subsysid].logfile = NULL; > snprintf (error_string_response, > sizeof(error_string_response), > "Can't open logfile '%s' for reason (%s).\n", > - file, strerror (errno)); > + file, error_str); > *error_string = error_string_response; > return (-1); > } > diff --git a/exec/main.c b/exec/main.c > index eb135e6..63a6d5f 100644 > --- a/exec/main.c > +++ b/exec/main.c > @@ -459,7 +459,11 @@ static void corosync_mlockall (void) > #else > res = mlockall (MCL_CURRENT | MCL_FUTURE); > if (res == -1) { > - log_printf (LOGSYS_LEVEL_WARNING, "Could not lock memory of > service to avoid page faults: %s\n", strerror (errno)); > + char error_str[100]; > + strerror_r (errno, error_str, 100); > + log_printf (LOGSYS_LEVEL_WARNING, > + "Could not lock memory of service to avoid page faults: > %s\n", > + error_str); > }; > #endif > } > @@ -1132,9 +1136,11 @@ static void corosync_setscheduler (void) > global_sched_param.sched_priority = sched_priority; > res = sched_setscheduler (0, SCHED_RR, &global_sched_param); > if (res == -1) { > + char error_str[100]; > + strerror_r (errno, error_str, 100); > global_sched_param.sched_priority = 0; > log_printf (LOGSYS_LEVEL_WARNING, "Could not set > SCHED_RR at priority %d: %s\n", > - global_sched_param.sched_priority, strerror > (errno)); > + global_sched_param.sched_priority, error_str); > > logsys_thread_priority_set (SCHED_OTHER, NULL, 1); > } else { > @@ -1155,7 +1161,11 @@ static void corosync_setscheduler (void) > } > } > } else { > - log_printf (LOGSYS_LEVEL_WARNING, "Could not get maximum > scheduler priority: %s\n", strerror (errno)); > + char error_str[100]; > + strerror_r (errno, error_str, 100); > + log_printf (LOGSYS_LEVEL_WARNING, > + "Could not get maximum scheduler priority: %s\n", > + error_str); > sched_priority = 0; > } > #else > diff --git a/exec/totemconfig.c b/exec/totemconfig.c > index aa54ad3..e6ba941 100644 > --- a/exec/totemconfig.c > +++ b/exec/totemconfig.c > @@ -690,12 +690,14 @@ static int read_keyfile ( > int res; > ssize_t expected_key_len = sizeof (totem_config->private_key); > int saved_errno; > + char error_str[100]; > > fd = open (key_location, O_RDONLY); > if (fd == -1) { > + strerror_r (errno, error_str, 100); > snprintf (error_string_response, sizeof(error_string_response), > "Could not open %s: %s\n", > - key_location, strerror (errno)); > + key_location, error_str); > goto parse_error; > } > > @@ -704,9 +706,10 @@ static int read_keyfile ( > close (fd); > > if (res == -1) { > + strerror_r (errno, error_str, 100); > snprintf (error_string_response, sizeof(error_string_response), > "Could not read %s: %s\n", > - key_location, strerror (saved_errno)); > + key_location, error_str); > goto parse_error; > } > > diff --git a/exec/totemsrp.c b/exec/totemsrp.c > index 24c018e..e21a0c6 100644 > --- a/exec/totemsrp.c > +++ b/exec/totemsrp.c > @@ -3071,15 +3071,19 @@ static void memb_ring_id_create_or_load ( > umask(0); > fd = open (filename, O_CREAT|O_RDWR, 0700); > if (fd == -1) { > + char error_str[100]; > + strerror_r(errno, error_str, 100); > log_printf (instance->totemsrp_log_level_warning, > - "Couldn't create %s %s\n", filename, strerror > (errno)); > + "Couldn't create %s %s\n", filename, error_str); > } > res = write (fd, &memb_ring_id->seq, sizeof (unsigned long > long)); > assert (res == sizeof (unsigned long long)); > close (fd); > } else { > + char error_str[100]; > + strerror_r(errno, error_str, 100); > log_printf (instance->totemsrp_log_level_warning, > - "Couldn't open %s %s\n", filename, strerror (errno)); > + "Couldn't open %s %s\n", filename, error_str); > } > > totemip_copy(&memb_ring_id->rep, &instance->my_id.addr[0]); > @@ -3105,9 +3109,11 @@ static void memb_ring_id_set_and_store ( > fd = open (filename, O_CREAT|O_RDWR, 0777); > } > if (fd == -1) { > + char error_str[100]; > + strerror_r(errno, error_str, 100); > log_printf (instance->totemsrp_log_level_warning, > "Couldn't store new ring id %llx to stable storage > (%s)\n", > - instance->my_ring_id.seq, strerror (errno)); > + instance->my_ring_id.seq, error_str); > assert (0); > return; > } > diff --git a/exec/totemudp.c b/exec/totemudp.c > index 6d67150..33c543c 100644 > --- a/exec/totemudp.c > +++ b/exec/totemudp.c > @@ -1385,10 +1385,14 @@ static void timer_function_netif_check_timeout ( > static void totemudp_traffic_control_set(struct totemudp_instance *instance, > int sock) > { > #ifdef SO_PRIORITY > - int prio = 6; /* TC_PRIO_INTERACTIVE */ > - > - if (setsockopt(sock, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(int))) > - log_printf (instance->totemudp_log_level_warning, "Could not > set traffic priority. (%s)\n", strerror (errno)); > + int prio = 6; /* TC_PRIO_INTERACTIVE */ > + char error_str[100]; > + > + if (setsockopt(sock, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(int))) { > + strerror_r (errno, error_str, 100); > + log_printf (instance->totemudp_log_level_warning, > + "Could not set traffic priority. (%s)\n", error_str); > + } > #endif > } > > @@ -1426,7 +1430,10 @@ static int totemudp_build_sockets_ip ( > totemip_nosigpipe (sockets->mcast_recv); > res = fcntl (sockets->mcast_recv, F_SETFL, O_NONBLOCK); > if (res == -1) { > - log_printf (instance->totemudp_log_level_warning, "Could not > set non-blocking operation on multicast socket: %s\n", strerror (errno)); > + char error_str[100]; > + strerror_r (errno, error_str, 100); > + log_printf (instance->totemudp_log_level_warning, > + "Could not set non-blocking operation on multicast > socket: %s\n", error_str); > return (-1); > } > > @@ -1462,7 +1469,10 @@ static int totemudp_build_sockets_ip ( > totemip_nosigpipe (sockets->mcast_send); > res = fcntl (sockets->mcast_send, F_SETFL, O_NONBLOCK); > if (res == -1) { > - log_printf (instance->totemudp_log_level_warning, "Could not > set non-blocking operation on multicast socket: %s\n", strerror (errno)); > + char error_str[100]; > + strerror_r (errno, error_str, 100); > + log_printf (instance->totemudp_log_level_warning, > + "Could not set non-blocking operation on multicast > socket: %s\n", error_str); > return (-1); > } > > @@ -1495,7 +1505,10 @@ static int totemudp_build_sockets_ip ( > totemip_nosigpipe (sockets->token); > res = fcntl (sockets->token, F_SETFL, O_NONBLOCK); > if (res == -1) { > - log_printf (instance->totemudp_log_level_warning, "Could not > set non-blocking operation on token socket: %s\n", strerror (errno)); > + char error_str[100]; > + strerror_r (errno, error_str, 100); > + log_printf (instance->totemudp_log_level_warning, > + "Could not set non-blocking operation on token socket: > %s\n", error_str); > return (-1); > } > > diff --git a/lcr/uis.c b/lcr/uis.c > index 6431c7f..004c464 100755 > --- a/lcr/uis.c > +++ b/lcr/uis.c > @@ -96,7 +96,9 @@ static void uis_lcr_bind (int *server_fd) > > res = bind (fd, (struct sockaddr *)&un_addr, AIS_SUN_LEN(&un_addr)); > if (res) { > - printf ("Could not bind AF_UNIX: %s\n", strerror (errno)); > + char error_str[100]; > + strerror_r (errno, error_str, 100); > + printf ("Could not bind AF_UNIX: %s\n", error_str); > } > listen (fd, SERVER_BACKLOG); > *server_fd = fd;
_______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
