Sort of fix for the forms problem
Damian Ivereigh
damian at cisco.com
Fri Jan 5 04:00:27 GMT 2001
Lets try that again *with* the patch!
Damian
Damian Ivereigh wrote:
>
> OK, here is a patch which should at least stop the garbage being
> written to the data file.
>
> It still isn't perfect since if you have multiple users connected each
> reading and writing the whole forms list, the chances of an actual
> delete or update working are pretty small (the other users will just
> overwrite it).
>
> I am wondering if this whole area could do with a re-write. There is
> no good reason for the entire list to be pulled in just for an add,
> update or delete. Not only is this a performance hit, it messes up
> with multiple users.
>
> Would anyone mind if I just re-did that bit of the code?
>
> Damian
> --
> Damian Ivereigh
> CEPS Team Lead
> http://wwwin-print.cisco.com
> Desk: +61 2 8446 6344
> Mob: +61 418 217 582
--
Damian Ivereigh
CEPS Team Lead
http://wwwin-print.cisco.com
Desk: +61 2 8446 6344
Mob: +61 418 217 582
-------------- next part --------------
Index: rpc_server/srv_spoolss_nt.c
===================================================================
RCS file: /cvsroot/samba/source/rpc_server/srv_spoolss_nt.c,v
retrieving revision 1.150
diff -c -r1.150 srv_spoolss_nt.c
*** rpc_server/srv_spoolss_nt.c 2000/12/21 23:23:34 1.150
--- rpc_server/srv_spoolss_nt.c 2001/01/05 04:48:31
***************
*** 4535,4565 ****
/* construct the list of form structures */
for (i=0; i<*numofforms; i++) {
! DEBUGADD(6,("Filling form number [%d]\n",i));
! fill_form_1(&forms_1[i], &list[i]);
}
- safe_free(list);
-
/* check the required size. */
for (i=0; i<*numofforms; i++) {
! DEBUGADD(6,("adding form [%d]'s size\n",i));
! buffer_size += spoolss_size_form_1(&forms_1[i]);
}
*needed=buffer_size;
if (!alloc_buffer_size(buffer, buffer_size)){
safe_free(forms_1);
return ERROR_INSUFFICIENT_BUFFER;
}
/* fill the buffer with the form structures */
for (i=0; i<*numofforms; i++) {
! DEBUGADD(6,("adding form [%d] to buffer\n",i));
! new_smb_io_form_1("", buffer, &forms_1[i], 0);
}
safe_free(forms_1);
if (*needed > offered) {
--- 4551,4587 ----
/* construct the list of form structures */
for (i=0; i<*numofforms; i++) {
! if (list[i].name[0]) {
! DEBUGADD(6,("Filling form number [%d]\n",i));
! fill_form_1(&forms_1[i], &list[i]);
! }
}
/* check the required size. */
for (i=0; i<*numofforms; i++) {
! if (list[i].name[0]) {
! DEBUGADD(6,("adding form [%d]'s size\n",i));
! buffer_size += spoolss_size_form_1(&forms_1[i]);
! }
}
*needed=buffer_size;
if (!alloc_buffer_size(buffer, buffer_size)){
+ safe_free(list);
safe_free(forms_1);
return ERROR_INSUFFICIENT_BUFFER;
}
/* fill the buffer with the form structures */
for (i=0; i<*numofforms; i++) {
! if (list[i].name[0]) {
! DEBUGADD(6,("adding form [%d] to buffer\n",i));
! new_smb_io_form_1("", buffer, &forms_1[i], 0);
! }
}
+ safe_free(list);
safe_free(forms_1);
if (*needed > offered) {
Index: printing/nt_printing.c
===================================================================
RCS file: /cvsroot/samba/source/printing/nt_printing.c,v
retrieving revision 1.122
diff -c -r1.122 nt_printing.c
*** printing/nt_printing.c 2001/01/04 19:27:07 1.122
--- printing/nt_printing.c 2001/01/05 04:46:23
***************
*** 111,116 ****
--- 118,125 ----
/* allocate space and populate the list in correct order */
if (i+1 > n) {
*list = Realloc(*list, sizeof(nt_forms_struct)*(i+1));
+ /* Make sure new space is zeroed */
+ memset((*list) + n, '\0', sizeof(nt_forms_struct)*(i+1-n));
n = i+1;
}
(*list)[i] = form;
***************
*** 137,142 ****
--- 146,155 ----
int i;
for (i=0;i<number;i++) {
+ /* Skip any empty ones */
+ if (*(*list)[i].name == '\0') {
+ continue;
+ }
/* save index, so list is rebuilt in correct order */
len = tdb_pack(buf, sizeof(buf), "dddddddd",
i, (*list)[i].flag, (*list)[i].width, (*list)[i].length,
***************
*** 241,246 ****
--- 254,261 ----
*ret = ERROR_NOT_ENOUGH_MEMORY;
return False;
}
+ /* Zap name from list */
+ (*list)[n].name[0]='\0';
return True;
}
More information about the samba-technical
mailing list