> Hi Steve,
>
Hallo Karl Heinz,
> I patched the source and after that, the dspam-daemon eats all cpu an
> our servers... so, its getting worse with that patch :(
>
> any other ideas?
>
Could you paste the following lines into a file called test.c (without the
first and the last line. I mean the one containing "-----"):
-----
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
int
main ()
{
char session[64];
char digit[16];
int pid, j=0;
long timenow;
struct timeval tp;
struct timezone tzp;
gettimeofday(&tp, &tzp);
timenow = (long) time (NULL);
srand ((long) time (NULL)<< (long) getpid ());
pid = getpid ();
snprintf (session, sizeof (session), "%8lx%d", (long) time (NULL), pid);
for (j = 0; j < 2; j++)
{
snprintf (digit, sizeof(digit), "%d", rand ());
strncat (session, digit, sizeof(session));
}
snprintf (digit, sizeof(digit), "%d", (unsigned int)tp.tv_sec - (unsigned
int)tp.tv_usec);
strncat (session, digit, sizeof(session));
snprintf (digit, sizeof(digit), "%d", (unsigned int)tp.tv_usec);
strncat (session, digit, sizeof(session));
printf ("%s\n", session);
return 0;
}
-----
And then compile it with:
gcc -o test test.c
And then run it to create 1000 numbers and measure how long it takes:
time for foo in $(seq 1 1 1000);do ./test3;done
The code above is +/- what DSPAM does when creating the signature BUT I added
two additional computations at the end so that the signature should be enough
long. I avoided additional calls to rand() since I assume rand() to be slow or
very CPU intensive on your system.
If the code from above is eating all your CPU when running the test then try
this one here:
-----
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
int
main ()
{
char session[64];
char digit[16];
int pid, j=0;
long timenow;
struct timeval tp;
struct timezone tzp;
gettimeofday(&tp, &tzp);
timenow = (long) time (NULL);
srand ((long) time (NULL)<< (long) getpid ());
pid = getpid ();
snprintf (session, sizeof (session), "%8lx%d", (long) time (NULL), pid);
for (j = 0; j < 2; j++)
{
snprintf (digit, sizeof(digit), "%d", rand ());
strncat (session, digit, sizeof(session));
}
snprintf (digit, sizeof(digit), "%d", (unsigned int)tp.tv_usec);
strncat (session, digit, sizeof(session));
printf ("%s\n", session);
return 0;
}
-----
Should be faster since it does not do much computation and it should deliver a
long enough signature since in your original mail you wrote that you miss one
digit and the last block above should add more then just one digit.
How much time does it take when you compute 1000 numbers with the first code
and how much time does it take when you compute 1000 numbers with the second
code? Is in both cases the signature long enough for you?
> greets,
> khp
>
Steve
> Steve schrieb:
> >> sure, that would be no problem
> >>
> > Since I don't know if the version you use is already patched or not I am
> going to write a small instruction what needs to be changed.
> >
> >
> > 1) Open src/mysql_drv.c
> > 2) Search for the function "_ds_create_signature_id"
> > 3) Search inside that function the following loop:
> > for (j = 0; j < 2; j++)
> > {
> > snprintf (digit, 6, "%d", rand ());
> > strlcat (session, digit, 64);
> > }
> > 4) Replace that loop with this here:
> > while (strlen(session) < sizeof(session)) {
> > snprintf (digit, sizeof(digit), "%d", rand());
> > strlcat (session, digit, sizeof(session));
> > }
> > 5) Save the file and then build DSPAM as usual.
> > 6) Let me know if that fixed your issue?
> >
> >
> > // Steve
> >
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Dspam-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspam-user