Skip to content

Commit

Permalink
Added Implementations for Timeval Linger Init functions
Browse files Browse the repository at this point in the history
Added Unix init implementations for linger, timeval structs

- Implemented omrsock_timeval_init and omrsock_linger_init
  for users to initialize the values inside timeval
  and linger structs.

Issue:# 5158

Signed-off-by: Haley Cao <haleycao88@hotmail.com>
  • Loading branch information
Haley Cao committed Jun 15, 2020
1 parent 63ae337 commit 5201aea
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions port/unix/omrsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,13 +662,25 @@ omrsock_inet_pton(struct OMRPortLibrary *portLibrary, int32_t addrFamily, const
int32_t
omrsock_timeval_init(struct OMRPortLibrary *portLibrary, omrsock_timeval_t handle, uint32_t secTime, uint32_t uSecTime)
{
return OMRPORT_ERROR_NOT_SUPPORTED_ON_THIS_PLATFORM;
if (NULL == handle) {
return OMRPORT_ERROR_INVALID_ARGUMENTS;
}
memset(handle, 0, sizeof(OMRTimeval));
handle->data.tv_sec = secTime;
handle->data.tv_usec = uSecTime;
return 0;
}

int32_t
omrsock_linger_init(struct OMRPortLibrary *portLibrary, omrsock_linger_t handle, int32_t enabled, uint16_t timeout)
{
return OMRPORT_ERROR_NOT_SUPPORTED_ON_THIS_PLATFORM;
if (NULL == handle) {
return OMRPORT_ERROR_INVALID_ARGUMENTS;
}
memset(handle, 0, sizeof(OMRLinger));
handle->data.l_onoff = enabled;
handle->data.l_linger = (int32_t)timeout; /* Cast to in32_t because WIN system takes uint16_t*/
return 0;
}

int32_t
Expand Down

0 comments on commit 5201aea

Please sign in to comment.