fix: wrapper load so from /usr/local/lib/ on mac (#30822)

* fix: wrapper load so from /usr/local/lib/ on mac

* fix: check condition

* fix: check condition with not load

* fix: adjust comment text

* fix: adjust load order del taosGetInstallPath

* fix: restore load dev path first
This commit is contained in:
Alex Duan 2025-04-19 11:24:11 +08:00 committed by GitHub
parent 2a6810b17a
commit b90be35d94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -50,11 +50,6 @@ static int32_t taosGetDevelopPath(char *driverPath, const char *driverName) {
return ret;
}
static int32_t taosGetInstallPath(char *driverPath, const char *driverName) {
tstrncpy(driverPath, driverName, PATH_MAX);
return 0;
}
int32_t taosDriverInit(EDriverType driverType) {
int32_t code = -1;
char driverPath[PATH_MAX + 32] = {0};
@ -67,13 +62,23 @@ int32_t taosDriverInit(EDriverType driverType) {
driverName = DRIVER_WSBSOCKET_NAME;
}
// load from develop build path
if (tsDriver == NULL && taosGetDevelopPath(driverPath, driverName) == 0) {
tsDriver = taosLoadDll(driverPath);
}
// load from system path
if (tsDriver == NULL) {
tsDriver = taosLoadDll(driverName);
}
if (tsDriver == NULL && taosGetInstallPath(driverPath, driverName) == 0) {
// load from install path on mac
#if defined(DARWIN)
if (tsDriver == NULL) {
snprintf(driverPath, PATH_MAX, "/usr/local/lib/%s", driverName);
tsDriver = taosLoadDll(driverPath);
}
#endif
if (tsDriver == NULL) {
printf("failed to load %s since %s [0x%X]\r\n", driverName, terrstr(), terrno);