• Post Reply Bookmark Topic Watch Topic
  • New Topic

invalid zip file

 
Yarik Chinskiy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a simple program that can read directory and create a zip file for each file in the directory. The zipping of all files is sumoltanious (one thread per zip). But they all share a buffer pool.
Some times I get invalid archives. Looks like the more files I zip the bigger chance that one of them is broken.
What is the proper way to close the zip file?
How to debug it?
Thank you.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a guess, I'd say that it sounds like there may be a problem with multiple threads accessing the same resource simultaneously - which is more likely to happen the more threads you have. Check your code carefully to make sure it's synchronized where appropriate.
 
Yarik Chinskiy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for the suggestoin.
I should probebly give more details to what happens.
Que - used by the reader and writer. Reader puts a buffer to the que, writer takes it of the que and writes to a file.
Pool - pool of buffers. Reader takes a buffer, reads from the file and passes it to a que. Writer releases the bufer back to the pool after it is written to the file.
All threads share the pool.
One que per reader/writer pair.
The pool access is synchronized.
How does reader use that bufer?
May be I need to clear a bufer every time I use it. But a buffer is just byte[]. How can you clean it? write 0's to it?
Thanks.
How does reader use that bufer?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!