r23779: Change from v2 or later to v3 or later.
[kai/samba.git] / source3 / profile / profile.c
index 187512333ccc83f9ca5df256a605265bd74db4a4..ebbcacac078dcb5b002656acd302cdfcd01244c6 100644 (file)
@@ -6,7 +6,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -42,13 +42,10 @@ BOOL do_profile_flag = False;
 BOOL do_profile_times = False;
 
 /****************************************************************************
-receive a set profile level message
+Set a profiling level.
 ****************************************************************************/
-void profile_message(int msg_type, struct process_id src, void *buf, size_t len)
+void set_profile_level(int level, struct server_id src)
 {
-        int level;
-
-       memcpy(&level, buf, sizeof(int));
 #ifdef WITH_PROFILE
        switch (level) {
        case 0:         /* turn off profiling */
@@ -93,11 +90,34 @@ void profile_message(int msg_type, struct process_id src, void *buf, size_t len)
 #endif /* WITH_PROFILE */
 }
 
+/****************************************************************************
+receive a set profile level message
+****************************************************************************/
+static void profile_message(struct messaging_context *msg_ctx,
+                           void *private_data,
+                           uint32_t msg_type,
+                           struct server_id src,
+                           DATA_BLOB *data)
+{
+        int level;
+
+       if (data->length != sizeof(level)) {
+               DEBUG(0, ("got invalid profile message\n"));
+               return;
+       }
+
+       memcpy(&level, data->data, sizeof(level));
+       set_profile_level(level, src);
+}
+
 /****************************************************************************
 receive a request profile level message
 ****************************************************************************/
-void reqprofile_message(int msg_type, struct process_id src,
-                       void *buf, size_t len)
+static void reqprofile_message(struct messaging_context *msg_ctx,
+                              void *private_data, 
+                              uint32_t msg_type, 
+                              struct server_id src,
+                              DATA_BLOB *data)
 {
         int level;
 
@@ -108,7 +128,8 @@ void reqprofile_message(int msg_type, struct process_id src,
 #endif
        DEBUG(1,("INFO: Received REQ_PROFILELEVEL message from PID %u\n",
                 (unsigned int)procid_to_pid(&src)));
-       message_send_pid(src, MSG_PROFILELEVEL, &level, sizeof(int), True);
+       messaging_send_buf(msg_ctx, src, MSG_PROFILELEVEL,
+                          (uint8 *)&level, sizeof(level));
 }
 
 /*******************************************************************
@@ -175,7 +196,7 @@ static void init_clock_gettime(void)
 }
 #endif
 
-BOOL profile_setup(BOOL rdonly)
+BOOL profile_setup(struct messaging_context *msg_ctx, BOOL rdonly)
 {
        struct shmid_ds shm_ds;
 
@@ -246,8 +267,12 @@ BOOL profile_setup(BOOL rdonly)
        }
 
        profile_p = &profile_h->stats;
-       message_register(MSG_PROFILE, profile_message);
-       message_register(MSG_REQ_PROFILELEVEL, reqprofile_message);
+       if (msg_ctx != NULL) {
+               messaging_register(msg_ctx, NULL, MSG_PROFILE,
+                                  profile_message);
+               messaging_register(msg_ctx, NULL, MSG_REQ_PROFILELEVEL,
+                                  reqprofile_message);
+       }
        return True;
 }
 
@@ -284,10 +309,11 @@ BOOL profile_setup(BOOL rdonly)
            "syscall_fchown",           /* PR_VALUE_SYSCALL_FCHOWN */
            "syscall_chdir",            /* PR_VALUE_SYSCALL_CHDIR */
            "syscall_getwd",            /* PR_VALUE_SYSCALL_GETWD */
-           "syscall_utime",            /* PR_VALUE_SYSCALL_UTIME */
+           "syscall_ntimes",           /* PR_VALUE_SYSCALL_NTIMES */
            "syscall_ftruncate",        /* PR_VALUE_SYSCALL_FTRUNCATE */
            "syscall_fcntl_lock",       /* PR_VALUE_SYSCALL_FCNTL_LOCK */
            "syscall_kernel_flock",     /* PR_VALUE_SYSCALL_KERNEL_FLOCK */
+           "syscall_linux_setlease",   /* PR_VALUE_SYSCALL_LINUX_SETLEASE */
            "syscall_fcntl_getlock",    /* PR_VALUE_SYSCALL_FCNTL_GETLOCK */
            "syscall_readlink",         /* PR_VALUE_SYSCALL_READLINK */
            "syscall_symlink",          /* PR_VALUE_SYSCALL_SYMLINK */
@@ -312,7 +338,7 @@ BOOL profile_setup(BOOL rdonly)
            "SMBunlock",        /* PR_VALUE_SMBUNLOCK */
            "SMBctemp",         /* PR_VALUE_SMBCTEMP */
            "SMBmknew",         /* PR_VALUE_SMBMKNEW */
-           "SMBchkpth",        /* PR_VALUE_SMBCHKPTH */
+           "SMBcheckpath",     /* PR_VALUE_SMBCHECKPATH */
            "SMBexit",          /* PR_VALUE_SMBEXIT */
            "SMBlseek",         /* PR_VALUE_SMBLSEEK */
            "SMBlockread",              /* PR_VALUE_SMBLOCKREAD */