mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
r1086: Add defer open test to check timeout on sharing violation open.
This has found some signing errors in the Samba3.0 implementation
of the deferred open code. Still working on these...
Jeremy
(This used to be commit 0068cb12ef
)
This commit is contained in:
parent
eaae8b6f5f
commit
a125e49d67
@ -409,3 +409,10 @@ NTTIME nttime_from_string(const char *s)
|
|||||||
{
|
{
|
||||||
return strtoull(s, NULL, 0);
|
return strtoull(s, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long long usec_time_diff(struct timeval *larget, struct timeval *smallt)
|
||||||
|
{
|
||||||
|
long long sec_diff = larget->tv_sec - smallt->tv_sec;
|
||||||
|
return (sec_diff * 1000000) + (long long)(larget->tv_usec - smallt->tv_usec);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1409,6 +1409,7 @@ BOOL torture_denytest1(int dummy)
|
|||||||
int fnum1, fnum2;
|
int fnum1, fnum2;
|
||||||
int i;
|
int i;
|
||||||
BOOL correct = True;
|
BOOL correct = True;
|
||||||
|
struct timeval tv, tv_start;
|
||||||
const char *fnames[2] = {"\\denytest1.dat", "\\denytest1.exe"};
|
const char *fnames[2] = {"\\denytest1.dat", "\\denytest1.exe"};
|
||||||
|
|
||||||
if (!torture_open_connection(&cli1)) {
|
if (!torture_open_connection(&cli1)) {
|
||||||
@ -1428,6 +1429,8 @@ BOOL torture_denytest1(int dummy)
|
|||||||
|
|
||||||
printf("testing %d entries\n", ARRAY_SIZE(denytable1));
|
printf("testing %d entries\n", ARRAY_SIZE(denytable1));
|
||||||
|
|
||||||
|
GetTimeOfDay(&tv_start);
|
||||||
|
|
||||||
for (i=0; i<ARRAY_SIZE(denytable1); i++) {
|
for (i=0; i<ARRAY_SIZE(denytable1); i++) {
|
||||||
enum deny_result res;
|
enum deny_result res;
|
||||||
const char *fname = fnames[denytable1[i].isexe];
|
const char *fname = fnames[denytable1[i].isexe];
|
||||||
@ -1461,7 +1464,12 @@ BOOL torture_denytest1(int dummy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (torture_showall || res != denytable1[i].result) {
|
if (torture_showall || res != denytable1[i].result) {
|
||||||
printf("%s %8s %10s %8s %10s %s (correct=%s)\n",
|
long long tdif;
|
||||||
|
GetTimeOfDay(&tv);
|
||||||
|
tdif = usec_time_diff(&tv, &tv_start);
|
||||||
|
tdif /= 1000;
|
||||||
|
printf("%lld: %s %8s %10s %8s %10s %s (correct=%s)\n",
|
||||||
|
tdif,
|
||||||
fname,
|
fname,
|
||||||
denystr(denytable1[i].deny1),
|
denystr(denytable1[i].deny1),
|
||||||
openstr(denytable1[i].mode1),
|
openstr(denytable1[i].mode1),
|
||||||
@ -1498,6 +1506,7 @@ BOOL torture_denytest2(int dummy)
|
|||||||
int i;
|
int i;
|
||||||
BOOL correct = True;
|
BOOL correct = True;
|
||||||
const char *fnames[2] = {"\\denytest2.dat", "\\denytest2.exe"};
|
const char *fnames[2] = {"\\denytest2.dat", "\\denytest2.exe"};
|
||||||
|
struct timeval tv, tv_start;
|
||||||
|
|
||||||
if (!torture_open_connection(&cli1) || !torture_open_connection(&cli2)) {
|
if (!torture_open_connection(&cli1) || !torture_open_connection(&cli2)) {
|
||||||
return False;
|
return False;
|
||||||
@ -1514,6 +1523,8 @@ BOOL torture_denytest2(int dummy)
|
|||||||
cli_close(cli1->tree, fnum1);
|
cli_close(cli1->tree, fnum1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GetTimeOfDay(&tv_start);
|
||||||
|
|
||||||
for (i=0; i<ARRAY_SIZE(denytable2); i++) {
|
for (i=0; i<ARRAY_SIZE(denytable2); i++) {
|
||||||
enum deny_result res;
|
enum deny_result res;
|
||||||
const char *fname = fnames[denytable2[i].isexe];
|
const char *fname = fnames[denytable2[i].isexe];
|
||||||
@ -1547,7 +1558,12 @@ BOOL torture_denytest2(int dummy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (torture_showall || res != denytable2[i].result) {
|
if (torture_showall || res != denytable2[i].result) {
|
||||||
printf("%s %8s %10s %8s %10s %s (correct=%s)\n",
|
long long tdif;
|
||||||
|
GetTimeOfDay(&tv);
|
||||||
|
tdif = usec_time_diff(&tv, &tv_start);
|
||||||
|
tdif /= 1000;
|
||||||
|
printf("%lld: %s %8s %10s %8s %10s %s (correct=%s)\n",
|
||||||
|
tdif,
|
||||||
fname,
|
fname,
|
||||||
denystr(denytable2[i].deny1),
|
denystr(denytable2[i].deny1),
|
||||||
openstr(denytable2[i].mode1),
|
openstr(denytable2[i].mode1),
|
||||||
|
@ -1757,6 +1757,66 @@ static BOOL run_unlinktest(int dummy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
test how many open files this server supports on the one socket
|
||||||
|
*/
|
||||||
|
|
||||||
|
static BOOL run_deferopen(struct cli_state *cli, int dummy)
|
||||||
|
{
|
||||||
|
char *fname = "\\defer_open_test.dat";
|
||||||
|
int retries=4;
|
||||||
|
int i = 0;
|
||||||
|
BOOL correct = True;
|
||||||
|
|
||||||
|
if (retries <= 0) {
|
||||||
|
printf("failed to connect\n");
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Testing deferred open requests.\n");
|
||||||
|
|
||||||
|
while (i < 4) {
|
||||||
|
int fnum = -1;
|
||||||
|
do {
|
||||||
|
fnum = cli_nt_create_full(cli->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
|
||||||
|
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE,
|
||||||
|
NTCREATEX_DISP_OPEN_IF, 0, 0);
|
||||||
|
if (fnum != -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (NT_STATUS_EQUAL(cli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION));
|
||||||
|
|
||||||
|
if (fnum == -1) {
|
||||||
|
fprintf(stderr,"Failed to open %s, error=%s\n", fname, cli_errstr(cli->tree));
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("pid %u open %d\n", getpid(), i);
|
||||||
|
|
||||||
|
sleep(10);
|
||||||
|
i++;
|
||||||
|
if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum))) {
|
||||||
|
fprintf(stderr,"Failed to close %s, error=%s\n", fname, cli_errstr(cli->tree));
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
sleep(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, fname))) {
|
||||||
|
/* All until the last unlink will fail with sharing violation. */
|
||||||
|
if (!NT_STATUS_EQUAL(cli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)) {
|
||||||
|
printf("unlink of %s failed (%s)\n", fname, cli_errstr(cli->tree));
|
||||||
|
correct = False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("deferred test finished\n");
|
||||||
|
if (!torture_close_connection(cli)) {
|
||||||
|
correct = False;
|
||||||
|
}
|
||||||
|
return correct;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
test how many open files this server supports on the one socket
|
test how many open files this server supports on the one socket
|
||||||
*/
|
*/
|
||||||
@ -4089,6 +4149,7 @@ static struct {
|
|||||||
#if 1
|
#if 1
|
||||||
{"OPENATTR", run_openattrtest, 0},
|
{"OPENATTR", run_openattrtest, 0},
|
||||||
#endif
|
#endif
|
||||||
|
{"DEFER_OPEN", run_deferopen, FLAG_MULTIPROC},
|
||||||
{"XCOPY", run_xcopy, 0},
|
{"XCOPY", run_xcopy, 0},
|
||||||
{"RENAME", run_rename, 0},
|
{"RENAME", run_rename, 0},
|
||||||
{"DELETE", run_deletetest, 0},
|
{"DELETE", run_deletetest, 0},
|
||||||
|
Loading…
Reference in New Issue
Block a user