apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mladen Turk <mt...@apache.org>
Subject Some pending pathches for review/commit
Date Sun, 19 Sep 2004 15:47:48 GMT
Hi,

Trying for a third week :).


I've posted couple of patches for apr that seems to be
lost somewhere. There has been some discussion on
some of them, so I'm sending them all at once with
brief explanation for each.


1. test_makefile_win.patch

The apr/test/Makefile.win is missing a target to build
a readchild.exe that test is depending on but is never
build.


2. apr_random.patch

Set the hash tables to zero on init.
Although the test are passing now, some deep explanation
would be fine (probably from Ben Laurie).
I presume that the unix is setting the
memory to zero while on WIN32 it is set to 0xCD, and that's
why the expected test values are never met on WIN32.

3. apr_thread_join.patch

Makes the threads to behave like on posix.
If the thread is created without APR_DETACH expect that
the thread_join will be called, so don't close the handle
in advance, if the thread has already finished.


4. file_stat.patch

Fixes obtaining security info on files for NT+. The current
implementation works only with directories, but for files
we need the READ_CONTROL open flag.

5. sha2.patch

Just fixes the compile time warnings caused by assigning 64
bit values to 32 bit integers, by casting them to unsigned int.


Regards,
MT.



Index: Makefile.win
===================================================================
RCS file: /home/cvspublic/apr/test/Makefile.win,v
retrieving revision 1.22
diff -u -r1.22 Makefile.win
--- Makefile.win    26 Jul 2004 15:21:59 -0000    1.22
+++ Makefile.win    26 Aug 2004 16:34:40 -0000
@@ -6,7 +6,8 @@
      sendfile.exe \
      proc_child.exe \
          tryread.exe \
-    occhild.exe\
+    occhild.exe \
+    readchild.exe \
      sockchild.exe \
      testlockperf.exe \
      testshmproducer.exe \
@@ -39,6 +40,9 @@

  occhild.exe: occhild.obj $(LOCAL_LIBS)
      $(LINK) occhild.obj $(LOCAL_LIBS) $(ALL_LIBS)
+
+readchild.exe: readchild.obj $(LOCAL_LIBS)
+    $(LINK) readchild.obj $(LOCAL_LIBS) $(ALL_LIBS)

  proc_child.exe: proc_child.obj $(LOCAL_LIBS)
      $(LINK) /debug /subsystem:console /machine:I386 \




Index: apr_random.c
===================================================================
RCS file: /home/cvspublic/apr/random/unix/apr_random.c,v
retrieving revision 1.9
diff -u -r1.9 apr_random.c
--- apr_random.c    28 Feb 2004 18:31:41 -0000    1.9
+++ apr_random.c    28 Aug 2004 14:35:06 -0000
@@ -111,8 +111,8 @@
                      /2)*g->pool_hash->size*2;
      g->reseed_size = APR_RANDOM_DEFAULT_RESEED_SIZE;

-    g->H = apr_palloc(p,H_size(g));
-    g->H_waiting = apr_palloc(p,H_size(g));
+    g->H = apr_pcalloc(p,H_size(g));
+    g->H_waiting = apr_pcalloc(p,H_size(g));

      g->randomness = apr_palloc(p,B_size(g));
      g->random_bytes = 0;




Index: thread.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/win32/thread.c,v
retrieving revision 1.57
diff -u -r1.57 thread.c
--- thread.c    10 Jun 2004 10:57:25 -0000    1.57
+++ thread.c    28 Aug 2004 06:46:51 -0000
@@ -85,8 +85,9 @@
  {
      apr_status_t stat;
      unsigned temp;
+    HANDLE handle;

-    (*new) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t));
+    (*new) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t));

      if ((*new) == NULL) {
          return APR_ENOMEM;
@@ -105,14 +106,14 @@
       * same size as the calling thread.
       */
  #ifndef _WIN32_WCE
-    if (((*new)->td = (HANDLE)_beginthreadex(NULL,
+    if ((handle = (HANDLE)_beginthreadex(NULL,
                          attr && attr->stacksize > 0 ? attr->stacksize :
0,
                          (unsigned int (APR_THREAD_FUNC *)(void 
*))dummy_worker,
                          (*new), 0, &temp)) == 0) {
          return APR_FROM_OS_ERROR(_doserrno);
      }
  #else
-   if (((*new)->td = CreateThread(NULL,
+   if ((handle = CreateThread(NULL,
                          attr && attr->stacksize > 0 ? attr->stacksize :
0,
                          (unsigned int (APR_THREAD_FUNC *)(void 
*))dummy_worker,
                          (*new), 0, &temp)) == 0) {
@@ -120,9 +121,10 @@
      }
  #endif
      if (attr && attr->detach) {
-        CloseHandle((*new)->td);
-        (*new)->td = NULL;
+        CloseHandle(handle);
      }
+    else
+        (*new)->td = handle;

      return APR_SUCCESS;
  }
@@ -132,10 +134,8 @@
  {
      thd->exitval = retval;
      apr_pool_destroy(thd->pool);
+    thd->pool = NULL;
  #ifndef _WIN32_WCE
-    if (thd->td) {
-        CloseHandle(thd->td);
-    }
      _endthreadex(0);
  #else
      ExitThread(0);
@@ -146,15 +146,22 @@
  APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval,
                                            apr_thread_t *thd)
  {
-    apr_status_t rv;
-
+    apr_status_t rv = APR_SUCCESS;
+
+    if (!thd->td) {
+        /* Can not join on detached threads */
+        return APR_DETACH;
+    }
      rv = WaitForSingleObject(thd->td, INFINITE);
      if ( rv == WAIT_OBJECT_0 || rv == WAIT_ABANDONED) {
          *retval = thd->exitval;
-        return APR_SUCCESS;
      }
-    /* Wait failed */
-    return apr_get_os_error();;
+    else
+        rv = apr_get_os_error();
+    CloseHandle(thd->td);
+    thd->td = NULL;
+
+    return rv;
  }

  APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd)




Index: open.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/win32/open.c,v
retrieving revision 1.121
diff -u -r1.121 open.c
--- open.c    13 Feb 2004 09:38:27 -0000    1.121
+++ open.c    27 Aug 2004 19:25:47 -0000
@@ -324,6 +324,8 @@
          else {
              return APR_EACCES;
          }
+        if (flag & APR_READCONTROL)
+            oflags |= READ_CONTROL;
      }

      if (flag & APR_XTHREAD) {



Index: sha2.c
===================================================================
RCS file: /home/cvspublic/apr/random/unix/sha2.c,v
retrieving revision 1.6
diff -u -r1.6 sha2.c
--- sha2.c    28 Feb 2004 18:31:41 -0000    1.6
+++ sha2.c    27 Aug 2004 09:04:43 -0000
@@ -458,7 +458,7 @@
          /* Sanity check: */
          assert(context != (SHA256_CTX*)0 && data != (sha2_byte*)0);

-        usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH;
+        usedspace = (unsigned int)((context->bitcount >> 3) % 
SHA256_BLOCK_LENGTH);
          if (usedspace > 0) {
                  /* Calculate how much free space is available in the 
buffer */
                  freespace = SHA256_BLOCK_LENGTH - usedspace;
@@ -504,7 +504,7 @@

          /* If no digest buffer is passed, we don't bother doing this: */
          if (digest != (sha2_byte*)0) {
-                usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH;
+                usedspace = (unsigned int)((context->bitcount >> 3) % 
SHA256_BLOCK_LENGTH);
  #if !APR_IS_BIGENDIAN
                  /* Convert FROM host byte order */
                  REVERSE64(context->bitcount,context->bitcount);
@@ -780,7 +780,7 @@
          /* Sanity check: */
          assert(context != (SHA512_CTX*)0 && data != (sha2_byte*)0);

-        usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH;
+        usedspace = (unsigned int)((context->bitcount[0] >> 3) % 
SHA512_BLOCK_LENGTH);
          if (usedspace > 0) {
                  /* Calculate how much free space is available in the 
buffer */
                  freespace = SHA512_BLOCK_LENGTH - usedspace;
@@ -820,7 +820,7 @@
  void SHA512_Last(SHA512_CTX* context) {
          unsigned int    usedspace;

-        usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH;
+        usedspace = (unsigned int)((context->bitcount[0] >> 3) % 
SHA512_BLOCK_LENGTH);
  #if !APR_IS_BIGENDIAN
          /* Convert FROM host byte order */
          REVERSE64(context->bitcount[0],context->bitcount[0]);

Mime
View raw message