cleaned up ugly code
diff --git a/aos/linux_code/ipc_lib/shared_mem.c b/aos/linux_code/ipc_lib/shared_mem.c
index 4071ca2..c368e38 100644
--- a/aos/linux_code/ipc_lib/shared_mem.c
+++ b/aos/linux_code/ipc_lib/shared_mem.c
@@ -51,18 +51,20 @@
}
int shm;
-before:
if (to_create == create) {
- printf("shared_mem: creating %s\n", global_core->shm_name);
- shm = shm_open(global_core->shm_name, O_RDWR | O_CREAT | O_EXCL, 0666);
- global_core->owner = 1;
- if (shm == -1 && errno == EEXIST) {
- printf("shared_mem: going to shm_unlink(%s)\n", global_core->shm_name);
- if (shm_unlink(global_core->shm_name) == -1) {
- fprintf(stderr, "shared_mem: shm_unlink(%s) failed with of %d: %s\n",
- global_core->shm_name, errno, strerror(errno));
+ while (1) {
+ printf("shared_mem: creating %s\n", global_core->shm_name);
+ shm = shm_open(global_core->shm_name, O_RDWR | O_CREAT | O_EXCL, 0666);
+ global_core->owner = 1;
+ if (shm == -1 && errno == EEXIST) {
+ printf("shared_mem: going to shm_unlink(%s)\n", global_core->shm_name);
+ if (shm_unlink(global_core->shm_name) == -1) {
+ fprintf(stderr, "shared_mem: shm_unlink(%s) failed with of %d: %s\n",
+ global_core->shm_name, errno, strerror(errno));
+ break;
+ }
} else {
- goto before;
+ break;
}
}
} else {
@@ -118,8 +120,6 @@
if (global_core->owner) {
global_core->mem_struct->msg_alloc = (uint8_t *)address + global_core->size;
init_shared_mem_core(global_core->mem_struct);
- }
- if (global_core->owner) {
futex_set(&global_core->mem_struct->creation_condition);
} else {
if (futex_wait(&global_core->mem_struct->creation_condition) != 0) {