From 5ad5065a44a5a7b0487ffa03ca5adecff1ccb5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 28 Jun 2023 13:29:31 +0800 Subject: [PATCH] fix last user disappear --- cmoe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmoe.c b/cmoe.c index 7632f9d..dfa16ba 100644 --- a/cmoe.c +++ b/cmoe.c @@ -210,7 +210,7 @@ int main(int argc, char **argv) { } fp = fdopen(fd, "rb+"); return_count(fp, name, theme); - fclose(fp); + fflush(fp); flock(fd, LOCK_UN); close(fd); return 0; } reg = get_arg(reg + 4); @@ -232,13 +232,13 @@ int main(int argc, char **argv) { } fp = fdopen(fd, "rb+"); if(name_exist(fp, name)) { - fclose(fp); + fflush(fp); flock(fd, LOCK_UN); close(fd); http_error(HTTP400, "Name Exist."); return 7; } fseek(fp, 0, SEEK_END); add_user(name, 0, fp); - fclose(fp); + fflush(fp); flock(fd, LOCK_UN); close(fd); char* msg = "
Success.\r\n"; if(headers(strlen(msg), "text/html")) { write(1, "\0\0\0\0", 4);