diff options
author | Sverker Eriksson <[email protected]> | 2018-12-18 18:00:13 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2018-12-18 18:00:13 +0100 |
commit | 6f9314602ce3f29e3c87e44e2416753283ae8a06 (patch) | |
tree | 0ec11d993d0542c0c95d6f8ae490f14ae14caf56 /erts/emulator/sys/unix/erl_child_setup.c | |
parent | 44b09e036b31b29dddc3b178e8f6b9fc96a9a874 (diff) | |
parent | e2c0a692474af17232bbc89477b0c2ef654024f6 (diff) | |
download | otp-6f9314602ce3f29e3c87e44e2416753283ae8a06.tar.gz otp-6f9314602ce3f29e3c87e44e2416753283ae8a06.tar.bz2 otp-6f9314602ce3f29e3c87e44e2416753283ae8a06.zip |
Merge branch 'sverker/erl_child_setup/ERIERL-231/OTP-15488'
* sverker/erl_child_setup/ERIERL-231/OTP-15488:
Add assertions to forker and erl_child_setup
Diffstat (limited to 'erts/emulator/sys/unix/erl_child_setup.c')
-rw-r--r-- | erts/emulator/sys/unix/erl_child_setup.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/erts/emulator/sys/unix/erl_child_setup.c b/erts/emulator/sys/unix/erl_child_setup.c index 69fc6c2879..f2b2661eb7 100644 --- a/erts/emulator/sys/unix/erl_child_setup.c +++ b/erts/emulator/sys/unix/erl_child_setup.c @@ -92,7 +92,6 @@ static void ABORT(const char* fmt, ...) abort(); } -#ifdef DEBUG void erl_assert_error(const char* expr, const char* func, const char* file, int line) { @@ -102,7 +101,6 @@ erl_assert_error(const char* expr, const char* func, const char* file, int line) fflush(stderr); abort(); } -#endif void sys_sigblock(int sig) { @@ -230,8 +228,9 @@ start_new_child(int pipes[]) ErtsSysForkerProto proto; res = read(pipes[0], &proto, sizeof(proto)); if (res > 0) { - ASSERT(proto.action == ErtsSysForkerProtoAction_Ack); - ASSERT(res == sizeof(proto)); + ERTS_ASSERT(proto.magic_number == FORKER_MAGIC_NUMBER); + ERTS_ASSERT(proto.action == ErtsSysForkerProtoAction_Ack); + ERTS_ASSERT(res == sizeof(proto)); } } while(res < 0 && (errno == EINTR || errno == ERRNO_BLOCK)); @@ -467,6 +466,9 @@ main(int argc, char *argv[]) if (errno == EINTR) continue; DEBUG_PRINT("erl_child_setup failed to read from uds: %d, %d", res, errno); + if (errno != ECONNRESET) { + ABORT("Unexpected read error %d from beam", errno); + } _exit(0); } @@ -476,8 +478,9 @@ main(int argc, char *argv[]) } /* Since we use unix domain sockets and send the entire data in one go we *should* get the entire payload at once. */ - ASSERT(res == sizeof(proto)); - ASSERT(proto.action == ErtsSysForkerProtoAction_Start); + ERTS_ASSERT(res == sizeof(proto)); + ERTS_ASSERT(proto.magic_number == FORKER_MAGIC_NUMBER); + ERTS_ASSERT(proto.action == ErtsSysForkerProtoAction_Start); sys_sigblock(SIGCHLD); @@ -519,6 +522,7 @@ main(int argc, char *argv[]) ABORT("Failed to read from sigchld pipe: %d (%d)", res, errno); } + proto.magic_number = FORKER_MAGIC_NUMBER; proto.u.sigchld.port_id = get_port_id((pid_t)(ibuff[0])); if (proto.u.sigchld.port_id == THE_NON_VALUE) |