You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Vijay Kumar V <vi...@gmail.com> on 2005/02/01 13:26:06 UTC

Deadlock in batik

Hi Thomas,

We are using batik api to generate images from svg content.
However, when we issue a multi threaded request to generate the
images, it is getting blocked in

org.apache.batik.util.SoftReferenceCache.requestImpl method ( According
to the stack trace)

Im attaching the stack trace with this email...

Please let me know what needs to be done.

Im using batik 1.5.1 on windows 2000 machine.

Thanks in advance,

Regards,
Vijay

Re: Deadlock in batik

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Vijay,

    This is a unified diff, so it has the old lines
and the new lines, and the unchanged lines.  The
old lines start with a '-', the new lines start with
'+'.  The best thing to do is apply the patch with
the 'patch' application.  If you are on windows you
will have to track it down someplace.

Vijay Kumar V wrote:

> Hi Thomas,
> 
> I think im missing something......
> 
> Could you please explain the patch code which u have sent?
> particularly the line which reads...:
> 
> if (this != o)
> 
> 
> On Tue, 01 Feb 2005 08:57:48 -0500, Thomas DeWeese
> <Th...@kodak.com> wrote:
> 
>>Hi Vijay,
>>
>>   The patch is not in CVS so you must patch the existing code.
>>
>>Vijay Kumar V wrote:
>>
>>
>>>Thanks for your quick response. Should i download the source
>>>code again to get this patch or should i just copy the
>>>below synchronized code and replace it in cleared() method
>>>of SoftRefKey class.?
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>>For additional commands, e-mail: batik-users-help@xml.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Deadlock in batik

Posted by Vijay Kumar V <vi...@gmail.com>.
Hi Thomas,

I think im missing something......

Could you please explain the patch code which u have sent?
particularly the line which reads...:

if (this != o)


On Tue, 01 Feb 2005 08:57:48 -0500, Thomas DeWeese
<Th...@kodak.com> wrote:
> Hi Vijay,
> 
>    The patch is not in CVS so you must patch the existing code.
> 
> Vijay Kumar V wrote:
> 
> > Thanks for your quick response. Should i download the source
> > code again to get this patch or should i just copy the
> > below synchronized code and replace it in cleared() method
> > of SoftRefKey class.?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Deadlock in batik

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Vijay,

    The patch is not in CVS so you must patch the existing code.

Vijay Kumar V wrote:

> Thanks for your quick response. Should i download the source 
> code again to get this patch or should i just copy the 
> below synchronized code and replace it in cleared() method
> of SoftRefKey class.?


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Deadlock in batik

Posted by Vijay Kumar V <vi...@gmail.com>.
Hi Thomas,

Thanks for your quick response. Should i download the source 
code again to get this patch or should i just copy the 
below synchronized code and replace it in cleared() method
of SoftRefKey class.?

Thank you,
Vijay



On Tue, 01 Feb 2005 08:24:50 -0500, Thomas DeWeese
<Th...@kodak.com> wrote:
> Hi Vijay,
> 
>   I think the following patch will fix the problem.  Please
> report back if it does!  This would be a very odd case to happen
> but if your server was very busy I could see it happening.
> 
> Index: sources/org/apache/batik/util/SoftReferenceCache.java
> ===================================================================
> RCS file:
> /home/cvs/xml-batik/sources/org/apache/batik/util/SoftReferenceCache.java,v
> retrieving revision 1.8
> diff -w -u -r1.8 SoftReferenceCache.java
> --- sources/org/apache/batik/util/SoftReferenceCache.java       18 Aug
> 2004 07:15:50 -0000      1.8
> +++ sources/org/apache/batik/util/SoftReferenceCache.java       1 Feb
> 2005 12:36:38 -0000
> @@ -174,11 +174,17 @@
>              if (cache == null) return; // Can't really happen.
>              synchronized (cache) {
>                  Object o = cache.map.remove(key);
> -                if (this != o)
> +                if (this == o) {
> +                    // Notify other threads that they may have
> +                    // to provide this resource now.
> +                    cache.notifyAll();
> +                } else {
>                      // Must not have been ours put it back...
>                      // Can happen if a clear is done.
>                      cache.map.put(key, o);
>              }
> +
> +            }
>          }
>      }
>  }
> 
> Vijay Kumar V wrote:
> 
> > We are using batik api to generate images from svg content.
> > However, when we issue a multi threaded request to generate the
> > images, it is getting blocked in
> >
> > org.apache.batik.util.SoftReferenceCache.requestImpl method ( According
> > to the stack trace)
> >
> > Im attaching the stack trace with this email...
> >
> > Please let me know what needs to be done.
> >
> > Im using batik 1.5.1 on windows 2000 machine.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Deadlock in batik

Posted by Vijay Kumar V <vi...@gmail.com>.
Hi Thomas,

Thanks for this tip. This has not only solved the problem but 
also increased the performance by 50%. 

Thanks again.

PS: (Sorry for late response but i was re-assigned this task after a long time).

Regards,
Vijay


On Tue, 01 Feb 2005 08:24:50 -0500, Thomas DeWeese
<Th...@kodak.com> wrote:
> Hi Vijay,
> 
>   I think the following patch will fix the problem.  Please
> report back if it does!  This would be a very odd case to happen
> but if your server was very busy I could see it happening.
> 
> Index: sources/org/apache/batik/util/SoftReferenceCache.java
> ===================================================================
> RCS file:
> /home/cvs/xml-batik/sources/org/apache/batik/util/SoftReferenceCache.java,v
> retrieving revision 1.8
> diff -w -u -r1.8 SoftReferenceCache.java
> --- sources/org/apache/batik/util/SoftReferenceCache.java       18 Aug
> 2004 07:15:50 -0000      1.8
> +++ sources/org/apache/batik/util/SoftReferenceCache.java       1 Feb
> 2005 12:36:38 -0000
> @@ -174,11 +174,17 @@
>              if (cache == null) return; // Can't really happen.
>              synchronized (cache) {
>                  Object o = cache.map.remove(key);
> -                if (this != o)
> +                if (this == o) {
> +                    // Notify other threads that they may have
> +                    // to provide this resource now.
> +                    cache.notifyAll();
> +                } else {
>                      // Must not have been ours put it back...
>                      // Can happen if a clear is done.
>                      cache.map.put(key, o);
>              }
> +
> +            }
>          }
>      }
>  }
> 
> Vijay Kumar V wrote:
> 
> > We are using batik api to generate images from svg content.
> > However, when we issue a multi threaded request to generate the
> > images, it is getting blocked in
> >
> > org.apache.batik.util.SoftReferenceCache.requestImpl method ( According
> > to the stack trace)
> >
> > Im attaching the stack trace with this email...
> >
> > Please let me know what needs to be done.
> >
> > Im using batik 1.5.1 on windows 2000 machine.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Deadlock in batik

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Vijay,

   I think the following patch will fix the problem.  Please
report back if it does!  This would be a very odd case to happen
but if your server was very busy I could see it happening.

Index: sources/org/apache/batik/util/SoftReferenceCache.java
===================================================================
RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/util/SoftReferenceCache.java,v
retrieving revision 1.8
diff -w -u -r1.8 SoftReferenceCache.java
--- sources/org/apache/batik/util/SoftReferenceCache.java       18 Aug 
2004 07:15:50 -0000      1.8
+++ sources/org/apache/batik/util/SoftReferenceCache.java       1 Feb 
2005 12:36:38 -0000
@@ -174,11 +174,17 @@
              if (cache == null) return; // Can't really happen.
              synchronized (cache) {
                  Object o = cache.map.remove(key);
-                if (this != o)
+                if (this == o) {
+                    // Notify other threads that they may have
+                    // to provide this resource now.
+                    cache.notifyAll();
+                } else {
                      // Must not have been ours put it back...
                      // Can happen if a clear is done.
                      cache.map.put(key, o);
              }
+
+            }
          }
      }
  }


Vijay Kumar V wrote:

> We are using batik api to generate images from svg content.
> However, when we issue a multi threaded request to generate the
> images, it is getting blocked in
> 
> org.apache.batik.util.SoftReferenceCache.requestImpl method ( According
> to the stack trace)
> 
> Im attaching the stack trace with this email...
> 
> Please let me know what needs to be done.
> 
> Im using batik 1.5.1 on windows 2000 machine.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org