- HAL: some changes to linux and BSD hal implementations

pull/147/head
Michael Zillgith 7 years ago
parent 0e7fcb0c29
commit 47f540a4f9

@ -428,8 +428,12 @@ Socket_write(Socket self, uint8_t* buf, int size)
if (self->fd == -1)
return -1;
// MSG_NOSIGNAL - prevent send to signal SIGPIPE when peer unexpectedly closed the socket
return send(self->fd, buf, size, 0);
int retVal = send(self->fd, buf, size, 0);
if ((retVal == -1) && (errno == EAGAIN))
return 0;
else
return retVal;
}
void

@ -475,8 +475,13 @@ Socket_write(Socket self, uint8_t* buf, int size)
if (self->fd == -1)
return -1;
// MSG_NOSIGNAL - prevent send to signal SIGPIPE when peer unexpectedly closed the socket
return send(self->fd, buf, size, MSG_NOSIGNAL);
/* MSG_NOSIGNAL - prevent send to signal SIGPIPE when peer unexpectedly closed the socket */
int retVal = send(self->fd, buf, size, MSG_NOSIGNAL);
if ((retVal == -1) && (errno == EAGAIN))
return 0;
else
return retVal;
}
void

@ -25,10 +25,11 @@
#include <semaphore.h>
#include <unistd.h>
#include "hal_thread.h"
#include "libiec61850_platform_includes.h"
#include "lib_memory.h"
struct sThread {
struct sThread
{
ThreadExecutionFunction function;
void* parameter;
pthread_t pthread;
@ -39,9 +40,9 @@ struct sThread {
Semaphore
Semaphore_create(int initialValue)
{
char tmpname[] = {"/tmp/libiec61850.XXXXXX"};
mktemp(tmpname);
Semaphore self = sem_open(tmpname, O_CREAT, 0666, initialValue);
Semaphore self = GLOBAL_MALLOC(sizeof(sem_t));
sem_init((sem_t*) self, 0, initialValue);
return self;
}

Loading…
Cancel
Save