r25398: Parse loadparm context to all lp_*() functions.
[kai/samba.git] / source4 / torture / raw / lockbench.c
index 5e132a24cca34d6b67eb26d03327962300d3991b..97509606c3669fca91064ddc77c9ecd02cf42ba2 100644 (file)
@@ -7,7 +7,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,
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -31,6 +30,7 @@
 #include "lib/cmdline/popt_common.h"
 #include "libcli/composite/composite.h"
 #include "libcli/smb_composite/smb_composite.h"
+#include "param/param.h"
 
 #define BASEDIR "\\benchlock"
 #define FNAME BASEDIR "\\lock.dat"
@@ -190,7 +190,7 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te,
        io->in.service_type = state->service_type;
        io->in.credentials  = cmdline_credentials;
        io->in.fallback_to_anonymous = False;
-       io->in.workgroup    = lp_workgroup();
+       io->in.workgroup    = lp_workgroup(global_loadparm);
 
        /* kill off the remnants of the old connection */
        talloc_free(state->tree);
@@ -252,8 +252,7 @@ static void lock_completion(struct smbcli_request *req)
 
 static void echo_completion(struct smbcli_request *req)
 {
-       struct benchlock_state *state = talloc_get_type(req->async.private, 
-                                                       struct benchlock_state);
+       struct benchlock_state *state = (struct benchlock_state *)req->async.private;
        NTSTATUS status = smbcli_request_simple_recv(req);
        if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) ||
            NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) {
@@ -296,7 +295,7 @@ static void report_rate(struct event_context *ev, struct timed_event *te,
                p.in.size = 0;
                p.in.data = NULL;
                req = smb_raw_echo_send(state[i].tree->session->transport, &p);
-               req->async.private = state;
+               req->async.private = &state[i];
                req->async.fn      = echo_completion;
        }
 }
@@ -319,7 +318,7 @@ BOOL torture_bench_lock(struct torture_context *torture)
 
        progress = torture_setting_bool(torture, "progress", true);
 
-       nprocs = lp_parm_int(-1, "torture", "nprocs", 4);
+       nprocs = lp_parm_int(NULL, "torture", "nprocs", 4);
 
        state = talloc_zero_array(mem_ctx, struct benchlock_state, nprocs);
 
@@ -395,9 +394,10 @@ BOOL torture_bench_lock(struct torture_context *torture)
 
        smbcli_deltree(state[0].tree, BASEDIR);
        talloc_free(mem_ctx);
+       printf("\n");
        return ret;
 
 failed:
        talloc_free(mem_ctx);
-       return False;
+       return false;
 }