Skip to content

Commit

Permalink
Updated to support setting OSPC_DEFAULT_BLOCKING_FLAG.
Browse files Browse the repository at this point in the history
  • Loading branch information
di-shi committed Jul 18, 2024
1 parent f2908eb commit d64bfa7
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 6 deletions.
4 changes: 4 additions & 0 deletions RELNOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -797,3 +797,7 @@ Version 4.28.0 - 2024-07-08
* Added test features.
* Enabled without token element.
* Fixed fcntl typo.

Version 4.29.0 - 2024-0x-xx
* Updated to support setting OSPC_DEFAULT_BLOCKING_FLAG.

1 change: 1 addition & 0 deletions include/osp/osp.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "osp/ospossys.h"

/* exposed OSP API prototypes and constants */
#include "osp/ospsocketapi.h"
#include "osp/ospproviderapi.h"
#include "osp/osptransapi.h"
#include "osp/osplibversion.h"
Expand Down
1 change: 0 additions & 1 deletion include/osp/ospconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@
#define OSPC_DEFAULT_HTTPRETRYDELAY 2 /* seconds */
#define OSPC_DEFAULT_HTTPTIMEOUT 3 * 1000 /* 3 seconds in milliseconds */
#define OSPC_DEFAULT_PROBE_CONNECT 1 * 1000 /* 1 second in milliseconds */
#define OSPC_DEFAULT_BLOCKING_FLAG OSPC_FALSE

#endif /* _OSPCONFIG_H */
2 changes: 1 addition & 1 deletion include/osp/osplibversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define _OSPLIBVERSION_H

#define OSP_CLIENT_TOOLKIT_VERSION_MAJOR 4
#define OSP_CLIENT_TOOLKIT_VERSION_MINOR 28
#define OSP_CLIENT_TOOLKIT_VERSION_MINOR 29
#define OSP_CLIENT_TOOLKIT_VERSION_BUGFIX 0

#endif /* _OSPLIBVERSION_H */
34 changes: 34 additions & 0 deletions include/osp/ospsocketapi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**************************************************************************
*** COPYRIGHT (c) 2002 by TransNexus, Inc. ***
*** ***
*** This software is property of TransNexus, Inc. ***
*** This software is freely available under license from TransNexus. ***
*** The license terms and conditions for free use of this software by ***
*** third parties are defined in the OSP Toolkit Software License ***
*** Agreement (LICENSE.txt). Any use of this software by third ***
*** parties, which does not comply with the terms and conditions of the ***
*** OSP Toolkit Software License Agreement is prohibited without ***
*** the prior, express, written consent of TransNexus, Inc. ***
*** ***
*** Thank you for using the OSP ToolKit(TM). Please report any bugs, ***
*** suggestions or feedback to [email protected] ***
*** ***
**************************************************************************/

/* ospsocketapi.h - Prototypes for API socket functions. */
#ifndef _OSPSOCKETAPI_H
#define _OSPSOCKETAPI_H

/* Function Prototypes */
#ifdef __cplusplus
extern "C" {
#endif

void OSPPSockSetBlockingFlag(OSPTBOOL);
OSPTBOOL OSPPSockGetBlockingFlag();

#ifdef __cplusplus
}
#endif

#endif /* _OSPSOCKETAPI_H */
17 changes: 15 additions & 2 deletions src/ospsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@
#include <poll.h>
#endif

OSPTBOOL OSPVBlockingFlag = OSPC_FALSE;

void OSPPSockSetBlockingFlag(
OSPTBOOL ospvBlockingFlag) /* In - Blocking flag */
{
OSPVBlockingFlag = ospvBlockingFlag;
}

OSPTBOOL OSPPSockGetBlockingFlag()
{
return OSPVBlockingFlag;
}

int OSPPSockClose(
OSPTBOOL ospvGracefulSSLShutdown,
OSPTSOCKET *ospvSockFd,
Expand Down Expand Up @@ -190,7 +203,7 @@ int OSPPSockConnectAuditURL(
/*
** CHANGED OSPCFALSE -> OSPCTRUE in Sock conenct experimental
*/
errorcode = OSPPSockConnect(&(ospvHttp->SockFd), OSPC_DEFAULT_BLOCKING_FLAG,
errorcode = OSPPSockConnect(&(ospvHttp->SockFd), OSPVBlockingFlag,
ospvHttp->ServicePoint->IpAddr, ospvHttp->ServicePoint->Port, &timeout, &(ospvHttp->SSLSession));

if (errorcode == OSPC_ERR_NO_ERROR) {
Expand Down Expand Up @@ -320,7 +333,7 @@ int OSPPSockConnectServicePoint(
/*
* CHANGED OSPCFALSE -> TRUE
*/
errorcode = OSPPSockConnect(&(ospvHttp->SockFd), OSPC_DEFAULT_BLOCKING_FLAG,
errorcode = OSPPSockConnect(&(ospvHttp->SockFd), OSPVBlockingFlag,
ospvHttp->ServicePoint->IpAddr, ospvHttp->ServicePoint->Port, &timeout, &(ospvHttp->SSLSession));

if (errorcode == OSPC_ERR_NO_ERROR) {
Expand Down
4 changes: 3 additions & 1 deletion src/osptnprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ enum socket_stats {

static char tnBuffer[] = "test message";

OSPTBOOL OSPVBlockingFlag;

/* OSPPTNProbe - probe systems and return response times */
int OSPPTNProbe( /*0 - normal; < 0 - error code */
OSPT_TN_PROBE *pProbeList, /* list to probe */
Expand Down Expand Up @@ -251,7 +253,7 @@ int OSPPTNProbeConnect( /* returns socket descriptor, < 0 == error */
if ((fdSocket >= 0) && uErr == 0) {

/* connect the socket */
uErr = OSPPSockConnect(&fdSocket, OSPC_DEFAULT_BLOCKING_FLAG, ipAddr, htons(OSPC_TN_UDP_ECHOPORT), &timeout, &sslsess);
uErr = OSPPSockConnect(&fdSocket, OSPVBlockingFlag, ipAddr, htons(OSPC_TN_UDP_ECHOPORT), &timeout, &sslsess);

if (uErr) {
fdSocket = -1;
Expand Down
19 changes: 18 additions & 1 deletion test/test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ int testOSPPProviderNew(OSPTPROVHANDLE *ProvHandle)

return errcode;
}

int testOSPPProviderDelete()
{
int errcode = 0;
Expand Down Expand Up @@ -643,6 +644,15 @@ int testOSPPProviderGetNumberOfServicePoints()
return errcode;
}

int testOSPPSockSetBlockingFlag()
{
int errcode = 0;

OSPPSockSetBlockingFlag(OSPC_TRUE);

return errcode;
}

int testOSPPTransactionSetPricingInfo()
{
int errcode = 0;
Expand Down Expand Up @@ -2632,6 +2642,9 @@ int testAPI(int apinumber)

switch (apinumber) {

case 0:
errcode = testOSPPSockSetBlockingFlag();
break;
case 1:
errcode = testOSPPProviderNew(&OSPVProviderHandle);
break;
Expand Down Expand Up @@ -3279,7 +3292,11 @@ int testMenu()
int funcnum;

if (!quietmode) {
printf("\nProvider API functions\n");
printf("\nSocket API functions\n");
printf("---------------------------------------------------------------------\n");
printf(" 0) SetBlockFlag\n");
printf("---------------------------------------------------------------------\n");
printf("Provider API functions\n");
printf("---------------------------------------------------------------------\n");
printf(" 1) New 2) Delete\n");
printf(" 3) For future Enhancements 4) SetServicePoints\n");
Expand Down

0 comments on commit d64bfa7

Please sign in to comment.