I wrote a shared library which has several functions. I am getting an unknown error when running my code.
Two of my functions may be called at the same time because I am running my code through another program. I've posted my code below.
Would char buffer[] and int *errnoOut cause an error, if the functions happen to update them simultaneously?
If so, what is the best way to deal with this?
Code:
// Send Data
int sendIPv6J(int sockfd, char buffer[], int *errnoOut) {
int n;
n = send(sockfd, buffer, strlen(buffer) + 1, 0);
if(n == -1) {
*errnoOut = errno;
return(-1);
} else {
*errnoOut = 0;
return(n);
}
}
// END
// Recv Data
int recvIPv6J(int sockfd, char buffer[], int maxBufferLength, int *errnoOut) {
int n;
n = recv(sockfd, buffer, maxBufferLength, 0);
if(n == -1) {
*errnoOut = errno;
return(-1);
} else {
*errnoOut = 0;
return(n);
}
}
// END