--- a/thermferm/server.c Sat Aug 16 17:11:09 2014 +0200 +++ b/thermferm/server.c Mon Aug 18 15:10:09 2014 +0200 @@ -25,14 +25,16 @@ #include "logger.h" #include "devices.h" #include "server.h" +#include "lcd-buffer.h" #include "xutil.h" extern int my_shutdown; extern int debug; +extern int run_pause; +extern int run_hold; extern sys_config Config; extern const char UNITMODE[5][8]; -extern const char UNITmode[5]; extern const char TEMPSTATE[3][8]; extern const char DEVTYPE[7][6]; extern const char DEVPRESENT[4][6]; @@ -963,6 +965,7 @@ if (current->profile) free(current->profile); current->profile = NULL; + previous->next = current->next; free(current); current = previous->next; return 1; @@ -990,7 +993,7 @@ units_list *unit, *tmpu; uuid_t uu; socklen_t fromlen; - int ival, i, rlen; + int ival, i, rc, rlen; float fval; opt = strtok(buf, " \0"); @@ -1038,6 +1041,16 @@ unit->prof_started = unit->prof_paused = (time_t)0; unit->PID_err_old = unit->PID_I_err = 0.0; + /* + * Block main process + */ + run_pause = TRUE; + for (;;) { + usleep(100000); + if (run_hold) + break; + } + if (Config.units == NULL) { Config.units = unit; } else { @@ -1048,6 +1061,8 @@ } } } + lcd_buf_reset(); + run_pause = FALSE; syslog(LOG_NOTICE, "Unit %s added", unit->uuid); srv_send((char *)"211 Unit %s added", unit->uuid); @@ -1055,7 +1070,21 @@ } if (strcmp(opt, (char *)"DEL") == 0) { - if (delete_Unit(param)) { + /* + * Block main process. + */ + run_pause = TRUE; + for (;;) { + usleep(100000); + if (run_hold) + break; + } + + rc = delete_Unit(param); + lcd_buf_reset(); + run_pause = FALSE; + + if (rc) { syslog(LOG_NOTICE, "Unit %s deleted", param); srv_send((char *)"211 Unit %s deleted", param); return 0;