I have found what appears to be a bug in libgpgme causing problems for the
application I'm developing (Licq).
I'm not sure exactly what happens, but Licq uses libgpgme for encryption/
decrypting messages and in my case I have done something wrong in my setup so
the decryption always fails.
The problem is after failing the decryption of some messages, I initiate a file
transfer in Licq which makes it open some network sockets and the next time
gpgme_op_decrypt() is called, it calls close() on what it thinks is an old pipe
but, since the file descriptor number has been reused, causes the socket to be
closed instead.
The effect is that in this situation, file transfers in Licq fails which is
very annoying.
I'm using gpgme 1.1.8 as shipped with debian/unstable for x86_64. Attached is a
patch which solves the problem by making sure gpg_cancel() clears the fd
variable after closing it so it won't close it again the next time it's called.
I guess the real fault is somewhere else since gpg_cancel() is called twice but
I haven't been able to trace this further and the patch is enough to solve the
problem for me.