s3-messages: only include messages.h where needed.
[samba.git] / source3 / profile / profile.c
index bdbd8057183b835abb14c2680bc12f83672f0e12..f081e1bbd7855c93f035a54e5119968f85b87696 100644 (file)
@@ -20,6 +20,8 @@
 */
 
 #include "includes.h"
+#include "librpc/gen_ndr/messaging.h"
+#include "messages.h"
 
 #ifdef WITH_PROFILE
 #define IPC_PERMS ((S_IRUSR | S_IWUSR) | S_IRGRP | S_IROTH)
 #ifdef WITH_PROFILE
 static int shm_id;
 static bool read_only;
-#if defined(HAVE_CLOCK_GETTIME)
-clockid_t __profile_clock;
-bool have_profiling_clock = False;
-#endif
 #endif
 
 struct profile_header *profile_h;
@@ -60,19 +58,6 @@ void set_profile_level(int level, struct server_id src)
                         (int)procid_to_pid(&src)));
                break;
        case 2:         /* turn on complete profiling */
-
-#if defined(HAVE_CLOCK_GETTIME)
-               if (!have_profiling_clock) {
-                       do_profile_flag = True;
-                       do_profile_times = False;
-                       DEBUG(1,("INFO: Profiling counts turned ON from "
-                               "pid %d\n", (int)procid_to_pid(&src)));
-                       DEBUGADD(1,("INFO: Profiling times disabled "
-                               "due to lack of a suitable clock\n"));
-                       break;
-               }
-#endif
-
                do_profile_flag = True;
                do_profile_times = True;
                DEBUG(1,("INFO: Full profiling turned ON from pid %d\n",
@@ -136,76 +121,12 @@ static void reqprofile_message(struct messaging_context *msg_ctx,
 /*******************************************************************
   open the profiling shared memory area
   ******************************************************************/
-
-#ifdef HAVE_CLOCK_GETTIME
-
-/* Find a clock. Just because the definition for a particular clock ID is
- * present doesn't mean the system actually supports it.
- */
-static void init_clock_gettime(void)
-{
-       struct timespec ts;
-
-       have_profiling_clock = False;
-
-#ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID
-       /* CLOCK_PROCESS_CPUTIME_ID is sufficiently fast that the
-        * always profiling times is plausible. Unfortunately on Linux
-        * it is only accurate if we can guarantee we will not be scheduled
-        * scheduled onto a different CPU between samples. Until there is
-        * some way to set processor affinity, we can only use this on
-        * uniprocessors.
-        */
-       if (!this_is_smp()) {
-           if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) == 0) {
-                   DEBUG(10, ("Using CLOCK_PROCESS_CPUTIME_ID "
-                               "for profile_clock\n"));
-                   __profile_clock = CLOCK_PROCESS_CPUTIME_ID;
-                   have_profiling_clock = True;
-           }
-       }
-#endif
-
-#ifdef HAVE_CLOCK_MONOTONIC
-       if (!have_profiling_clock &&
-           clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
-               DEBUG(10, ("Using CLOCK_MONOTONIC for profile_clock\n"));
-               __profile_clock = CLOCK_MONOTONIC;
-               have_profiling_clock = True;
-       }
-#endif
-
-#ifdef HAVE_CLOCK_REALTIME
-       /* POSIX says that CLOCK_REALTIME should be defined everywhere
-        * where we have clock_gettime...
-        */
-       if (!have_profiling_clock &&
-           clock_gettime(CLOCK_REALTIME, &ts) == 0) {
-               __profile_clock = CLOCK_REALTIME;
-               have_profiling_clock = True;
-
-               SMB_WARN(__profile_clock != CLOCK_REALTIME,
-                       ("forced to use a slow profiling clock"));
-       }
-
-#endif
-
-       SMB_WARN(have_profiling_clock == True,
-               ("could not find a working clock for profiling"));
-       return;
-}
-#endif
-
 bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
 {
        struct shmid_ds shm_ds;
 
        read_only = rdonly;
 
-#ifdef HAVE_CLOCK_GETTIME
-       init_clock_gettime();
-#endif
-
  again:
        /* try to use an existing key */
        shm_id = shmget(PROF_SHMEM_KEY, 0, 0);
@@ -227,7 +148,7 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
        
        profile_h = (struct profile_header *)shmat(shm_id, 0, 
                                                   read_only?SHM_RDONLY:0);
-       if ((long)profile_p == -1) {
+       if ((long)profile_h == -1) {
                DEBUG(0,("Can't attach to IPC area. Error was %s\n", 
                         strerror(errno)));
                return False;
@@ -290,6 +211,7 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
            "syscall_rmdir",            /* PR_VALUE_SYSCALL_RMDIR */
            "syscall_closedir",         /* PR_VALUE_SYSCALL_CLOSEDIR */
            "syscall_open",             /* PR_VALUE_SYSCALL_OPEN */
+           "syscall_createfile",       /* PR_VALUE_SYSCALL_CREATEFILE */
            "syscall_close",            /* PR_VALUE_SYSCALL_CLOSE */
            "syscall_read",             /* PR_VALUE_SYSCALL_READ */
            "syscall_pread",            /* PR_VALUE_SYSCALL_PREAD */
@@ -299,6 +221,7 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
            "syscall_sendfile",         /* PR_VALUE_SYSCALL_SENDFILE */
            "syscall_recvfile",         /* PR_VALUE_SYSCALL_RECVFILE */
            "syscall_rename",           /* PR_VALUE_SYSCALL_RENAME */
+           "syscall_rename_at",        /* PR_VALUE_SYSCALL_RENAME_AT */
            "syscall_fsync",            /* PR_VALUE_SYSCALL_FSYNC */
            "syscall_stat",             /* PR_VALUE_SYSCALL_STAT */
            "syscall_fstat",            /* PR_VALUE_SYSCALL_FSTAT */
@@ -312,6 +235,7 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
            "syscall_getwd",            /* PR_VALUE_SYSCALL_GETWD */
            "syscall_ntimes",           /* PR_VALUE_SYSCALL_NTIMES */
            "syscall_ftruncate",        /* PR_VALUE_SYSCALL_FTRUNCATE */
+           "syscall_fallocate",        /* PR_VALUE_SYSCALL_FALLOCATE */
            "syscall_fcntl_lock",       /* PR_VALUE_SYSCALL_FCNTL_LOCK */
            "syscall_kernel_flock",     /* PR_VALUE_SYSCALL_KERNEL_FLOCK */
            "syscall_linux_setlease",   /* PR_VALUE_SYSCALL_LINUX_SETLEASE */
@@ -323,6 +247,11 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
            "syscall_realpath",         /* PR_VALUE_SYSCALL_REALPATH */
            "syscall_get_quota",        /* PR_VALUE_SYSCALL_GET_QUOTA */
            "syscall_set_quota",        /* PR_VALUE_SYSCALL_SET_QUOTA */
+           "syscall_get_sd",           /* PR_VALUE_SYSCALL_GET_SD */
+           "syscall_set_sd",           /* PR_VALUE_SYSCALL_SET_SD */
+           "syscall_brl_lock",         /* PR_VALUE_SYSCALL_BRL_LOCK */
+           "syscall_brl_unlock",       /* PR_VALUE_SYSCALL_BRL_UNLOCK */
+           "syscall_brl_cancel",       /* PR_VALUE_SYSCALL_BRL_CANCEL */
            "SMBmkdir",         /* PR_VALUE_SMBMKDIR */
            "SMBrmdir",         /* PR_VALUE_SMBRMDIR */
            "SMBopen",          /* PR_VALUE_SMBOPEN */
@@ -447,6 +376,25 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
            "sync_browse_lists",        /* PR_VALUE_SYNC_BROWSE_LISTS */
            "run_elections",            /* PR_VALUE_RUN_ELECTIONS */
            "election",                 /* PR_VALUE_ELECTION */
+           "smb2_negprot",             /* PR_VALUE_SMB2_NEGPROT */
+           "smb2_sesssetup",           /* PR_VALUE_SMB2_SESSETUP */
+           "smb2_logoff",              /* PR_VALUE_SMB2_LOGOFF */
+           "smb2_tcon",                /* PR_VALUE_SMB2_TCON */
+           "smb2_tdis",                /* PR_VALUE_SMB2_TDIS */
+           "smb2_create",              /* PR_VALUE_SMB2_CREATE */
+           "smb2_close",               /* PR_VALUE_SMB2_CLOSE */
+           "smb2_flush",               /* PR_VALUE_SMB2_FLUSH */
+           "smb2_read",                /* PR_VALUE_SMB2_READ */
+           "smb2_write",               /* PR_VALUE_SMB2_WRITE */
+           "smb2_lock",                /* PR_VALUE_SMB2_LOCK */
+           "smb2_ioctl",               /* PR_VALUE_SMB2_IOCTL */
+           "smb2_cancel",              /* PR_VALUE_SMB2_CANCEL */
+           "smb2_keepalive",           /* PR_VALUE_SMB2_KEEPALIVE */
+           "smb2_find",                /* PR_VALUE_SMB2_FIND */
+           "smb2_notify",              /* PR_VALUE_SMB2_NOTIFY */
+           "smb2_getinfo",             /* PR_VALUE_SMB2_GETINFO */
+           "smb2_setinfo"              /* PR_VALUE_SMB2_SETINFO */
+           "smb2_break",               /* PR_VALUE_SMB2_BREAK */
            "" /* PR_VALUE_MAX */
        };