Skip to content

Commit

Permalink
smaxConnect() to default to localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Jan 17, 2025
1 parent 07cafda commit 1329f20
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/smax.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ int smaxConnectTo(const char *server) {
}

/**
* Initializes the SMA-X sharing library in this runtime instance.
* Initializes the SMA-X sharing library in this runtime instance, and connects to the SMA-X server.
* If the server was not explicitly configure previously it will try the default server
* (SMAX_DEFAULT_HOSTNAME = "smax"), or else localhost (127.0.0.1).
*
*
* \return X_SUCCESS If the library was successfully initialized
Expand Down Expand Up @@ -507,6 +509,14 @@ int smaxConnect() {
smaxAddDisconnectHook((void (*)) smaxReleaseWaits);

status = redisxConnect(redis, usePipeline);

// If failed on default host, then try localhost...
if(status && !server) {
xvprintf("Trying localhost...\n");
redisxSetHostname(redis, "127.0.0.1");
status = redisxConnect(redis, usePipeline);
}

if(status) {
smaxUnlockConfig();
return x_trace(fn, NULL, status);
Expand Down

0 comments on commit 1329f20

Please sign in to comment.