diff --git a/odyssey-dev.conf b/odyssey-dev.conf index 36bcd85e..73a8e708 100644 --- a/odyssey-dev.conf +++ b/odyssey-dev.conf @@ -1,4 +1,4 @@ -daemonize yes +daemonize no unix_socket_dir "/tmp" unix_socket_mode "0644" diff --git a/sources/frontend.c b/sources/frontend.c index 8b6ceae3..102d8a47 100644 --- a/sources/frontend.c +++ b/sources/frontend.c @@ -741,8 +741,23 @@ od_frontend_remote(od_client_t *client) } od_server_t *server; + od_instance_t *instance = client->global->instance; for (;;) { - machine_cond_wait(client->cond, UINT32_MAX); + /* we go to the eternal wait + * mode during normal work and set the timeout to the client + * in 1 minute to perform actions in the shutdown mode */ + while (1) { + if (machine_cond_wait(client->cond, 60000) == 0) { + break; + } + if (instance->shutdown_worker_id != -1) { + status = OD_ECLIENT_READ; + break; + } + } + + if (od_frontend_status_is_err(status)) + break; /* client operations */ status = od_frontend_ctl(client); diff --git a/sources/grac_shutdown_worker.h b/sources/grac_shutdown_worker.h index f3388020..9145527e 100644 --- a/sources/grac_shutdown_worker.h +++ b/sources/grac_shutdown_worker.h @@ -10,4 +10,4 @@ void od_grac_shutdown_worker(void *arg); -#endif /* ODYSSEY_GRAC_KILLER_H */ \ No newline at end of file +#endif /* ODYSSEY_GRAC_KILLER_H */ diff --git a/sources/sighandler.c b/sources/sighandler.c index 98970955..7b0d8d7f 100644 --- a/sources/sighandler.c +++ b/sources/sighandler.c @@ -19,6 +19,7 @@ od_system_gracefully_killer_invoke(od_system_t *system) "failed to invoke gracefully killer coroutine"); return NOT_OK_RESPONSE; } + instance->shutdown_worker_id = mid; return OK_RESPONSE; } diff --git a/test/ody-intergration-test/main b/test/ody-intergration-test/main new file mode 100755 index 00000000..be011b16 Binary files /dev/null and b/test/ody-intergration-test/main differ diff --git a/test/ody-intergration-test/pkg/cleint-server.go b/test/ody-intergration-test/pkg/cleint-server.go index 4ace49aa..4fdf0aee 100644 --- a/test/ody-intergration-test/pkg/cleint-server.go +++ b/test/ody-intergration-test/pkg/cleint-server.go @@ -184,8 +184,52 @@ func sigusr2Test( return nil } + + +func usrNoReadResultWhilesigusr2Test( + ctx context.Context, +) error { + + err := ensurePostgresqlRunning(ctx) + if err != nil { + return err + } + + if err := ensureOdysseyRunning(ctx); err != nil { + return err + } + + db, err := getConn(ctx, databaseName, 1) + + if _, err := db.Query("Select 42"); err != nil { + return err + } + + if _, err := signalToProc(syscall.SIGUSR2, "odyssey"); err != nil { + return err + } + + time.Sleep(30 * time.Second) + if err := db.Ping(); err != nil { + return err + } + time.Sleep(70 * time.Second) + if err := db.Ping(); err != nil { + fmt.Println(err) + return nil + } + + return fmt.Errorf("connection not closed!!!\n") +} + func odyClientServerInteractionsTestSet(ctx context.Context) error { + if err := usrNoReadResultWhilesigusr2Test(ctx); err != nil { + err = fmt.Errorf("usrNoReadResultWhilesigusr2 error %w", err) + fmt.Println(err) + return err + } + if err := onlineRestartTest(ctx); err != nil { err = fmt.Errorf("online restart error %w", err) fmt.Println(err) diff --git a/test/ody-intergration-test/pkg/main.go b/test/ody-intergration-test/pkg/main.go index 8847c377..dd7df624 100644 --- a/test/ody-intergration-test/pkg/main.go +++ b/test/ody-intergration-test/pkg/main.go @@ -8,7 +8,6 @@ import ( ) func main() { - ctx := context.Background() for _, f := range []func(ctx2 context.Context) error{