Uses an cli_echo() call to do so.
Based on code from <shargagan@novell.com>
Bug 11079 - libsmbclient not checking the cached connection alive status before re-using it from connection cache
https://bugzilla.samba.org/show_bug.cgi?id=11079
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): David Disseldorp <ddiss@samba.org>
Autobuild-Date(master): Fri Mar 20 13:48:26 CET 2015 on sn-devel-104
(cherry picked from commit
4f4151ea050a5f34e42d73a4bf9448c673a35787)
Autobuild-User(v4-1-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-1-test): Tue Mar 24 04:50:34 CET 2015 on sn-devel-104
bool no_pathinfo3;
bool no_nt_session;
struct policy_handle pol;
+ time_t last_echo_time;
SMBCSRV *next, *prev;
};
SMBC_check_server(SMBCCTX * context,
SMBCSRV * server)
{
+ time_t now;
+
if (!cli_state_is_connected(server->cli)) {
return 1;
}
+ now = time_mono(NULL);
+
+ if (server->last_echo_time == (time_t)0 ||
+ now > server->last_echo_time +
+ (server->cli->timeout/1000)) {
+ unsigned char data[16] = {0};
+ NTSTATUS status = cli_echo(server->cli,
+ 1,
+ data_blob_const(data, sizeof(data)));
+ if (!NT_STATUS_IS_OK(status)) {
+ return 1;
+ }
+ server->last_echo_time = now;
+ }
return 0;
}