Changeset: adafe325ac29 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/adafe325ac29
Modified Files:
        clients/Tests/exports.stable.out
        clients/mapiclient/mclient.c
        clients/mapiclient/msqldump.c
        clients/mapilib/connect.c
        clients/mapilib/mapi.c
        clients/mapilib/mapi.h
        clients/mapilib/mapi_intern.h
        tools/merovingian/daemon/snapshot.c
Branch: default
Log Message:

Replace mapi_set_application_name() with a call to get_bin_path()


diffs (134 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -717,7 +717,6 @@ int64_t mapi_rows_affected(MapiHdl hdl) 
 MapiMsg mapi_seek_row(MapiHdl hdl, int64_t rowne, int whence) 
__attribute__((__nonnull__(1)));
 MapiHdl mapi_send(Mapi mid, const char *cmd) __attribute__((__nonnull__(1)));
 MapiMsg mapi_setAutocommit(Mapi mid, bool autocommit) 
__attribute__((__nonnull__(1)));
-void mapi_set_application_name(const char *name);
 MapiMsg mapi_set_columnar_protocol(Mapi mid, bool columnar_protocol) 
__attribute__((__nonnull__(1)));
 MapiMsg mapi_set_size_header(Mapi mid, bool value) 
__attribute__((__nonnull__(1)));
 MapiMsg mapi_set_time_zone(Mapi mid, int seconds_east_of_utc) 
__attribute__((__nonnull__(1)));
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -3682,7 +3682,6 @@ main(int argc, char **argv)
        } else {
                mid = mapi_mapi(host, port, user, passwd, language, dbname);
        }
-       mapi_set_application_name("mclient");
        free(user_allocated);
        user_allocated = NULL;
        free(passwd_allocated);
diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -237,7 +237,6 @@ main(int argc, char **argv)
        } else {
                mid = mapi_mapi(host, port, user, passwd, "sql", dbname);
        }
-       mapi_set_application_name("msqldump");
        free(user_allocated);
        user_allocated = NULL;
        free(passwd_allocated);
diff --git a/clients/mapilib/connect.c b/clients/mapilib/connect.c
--- a/clients/mapilib/connect.c
+++ b/clients/mapilib/connect.c
@@ -385,6 +385,7 @@ static void
 send_all_clientinfo(Mapi mid)
 {
        msettings *mp = mid->settings;
+       void *free_this = NULL;
        if (!mid->clientinfo_supported)
                return;
        if (!msetting_bool(mp, MP_CLIENT_INFO))
@@ -398,8 +399,13 @@ send_all_clientinfo(Mapi mid)
                hostname[sizeof(hostname) - 1] = '\0';
        }
        const char *application_name = msetting_string(mp, 
MP_CLIENT_APPLICATION);
-       if (!application_name[0])
-               application_name = mapi_application_name;
+       if (!application_name[0]) {
+               application_name = get_bin_path();
+               if (application_name) {
+                       free_this = strdup(application_name);
+                       application_name = (const char*) 
basename((char*)application_name);
+               }
+       }
        const char *client_library = "libmapi " MONETDB_VERSION;
        const char *client_remark = msetting_string(mp, MP_CLIENT_REMARK);
        long pid = getpid();
@@ -425,7 +431,9 @@ send_all_clientinfo(Mapi mid)
 
        if (pos <= cap)
                mapi_Xcommand(mid, "clientinfo", buf);
+
        free(buf);
+       free(free_this);
 }
 
 static MapiMsg
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -794,8 +794,6 @@ static void mapi_store_bind(struct MapiR
 
 static ATOMIC_FLAG mapi_initialized = ATOMIC_FLAG_INIT;
 
-char mapi_application_name[256] = { 0 };
-
 /*
  * Blocking
  * --------
@@ -2121,15 +2119,6 @@ mapi_disconnect(Mapi mid)
        return MOK;
 }
 
-void
-mapi_set_application_name(const char *name)
-{
-       if (name)
-               strncpy(mapi_application_name, name, 
sizeof(mapi_application_name)-1);
-       else
-               mapi_application_name[0] = '\0';
-}
-
 /* Set callback function to retrieve or send file content for COPY
  * INTO queries.
  *
diff --git a/clients/mapilib/mapi.h b/clients/mapilib/mapi.h
--- a/clients/mapilib/mapi.h
+++ b/clients/mapilib/mapi.h
@@ -76,9 +76,6 @@ extern "C" {
 # endif
 #endif
 
-/* global state */
-mapi_export void mapi_set_application_name(const char *name);
-
 /* connection-oriented functions */
 mapi_export Mapi mapi_mapi(const char *host, int port, const char *username, 
const char *password, const char *lang, const char *dbname);
 mapi_export Mapi mapi_mapiuri(const char *url, const char *user, const char 
*pass, const char *lang);
diff --git a/clients/mapilib/mapi_intern.h b/clients/mapilib/mapi_intern.h
--- a/clients/mapilib/mapi_intern.h
+++ b/clients/mapilib/mapi_intern.h
@@ -310,8 +310,6 @@ MapiMsg mapi_Xcommand(Mapi mid, const ch
 
 extern const struct MapiStruct MapiStructDefaults;
 
-extern char mapi_application_name[];
-
 // 'settings' will be newly allocated if NULL
 Mapi mapi_new(msettings *settings);
 
diff --git a/tools/merovingian/daemon/snapshot.c 
b/tools/merovingian/daemon/snapshot.c
--- a/tools/merovingian/daemon/snapshot.c
+++ b/tools/merovingian/daemon/snapshot.c
@@ -114,7 +114,6 @@ snapshot_database_stream(char *dbname, s
                e = newErr("connection error: %s", mapi_error_str(conn));
                goto bailout;
        }
-       mapi_set_application_name("monetdbd");
        mapi_reconnect(conn);
        if (mapi_error(conn) != MOK) {
                e = newErr("connection error: %s", mapi_error_str(conn));
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to