#include <sys/ipc.h>
#include <sys/shm.h>
+#define MAX_SEMOP_RETRIES 500
int mutex_new(void)
{
static void para_semop(int id, struct sembuf *sops, int num)
{
- if (semop(id, sops, num) >= 0)
- return;
- PARA_WARNING_LOG("semop failed (%s), retrying\n", strerror(errno));
- while (semop(id, sops, num) < 0)
- ; /* nothing */
+ int i;
+
+ for (i = 0; i < MAX_SEMOP_RETRIES; i++)
+ if (semop(id, sops, num) >= 0)
+ return;
+ PARA_EMERG_LOG("semop failed %d times, aborting\n", MAX_SEMOP_RETRIES);
+ exit(EXIT_FAILURE);
}
/**