Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win32 Ignoring Mutex and Having multiple instances #641

Closed
CeruleanSky opened this issue Sep 3, 2015 · 4 comments

Comments

Projects
None yet
4 participants
@CeruleanSky
Copy link

commented Sep 3, 2015

'Geany' no longer detects if there is an instance of itself already running, thus multiple instances are starting up, instead of files being opened in the current instance.

I doubt it is a "#ifdef HAVE_SOCKET" not being defined since the mutexs (called mutants in win32) are being created with the name 'Geany'.

I suspect it had to do with recent cleanups and changes in https://github.com/geany/geany/commits/c5b0fc459a1251c824a44edb5dfab4a8feb0bd00/src/socket.c

Using geany 1.25 with windows 7 64bit.

screenshot_of_mutants

@CeruleanSky CeruleanSky changed the title Win32 Ignoring Mutex and Having nultiple instances Win32 Ignoring Mutex and Having multiple instances Sep 3, 2015

@elextr elextr added the windows label Sep 9, 2015

@eht16

This comment has been minimized.

Copy link
Member

commented Sep 12, 2015

What exactly are we talking about here?
Executing geany.exe after an instance is already running or rather opening additional files into an already running instance, e.g. with the Explorer context menu item "Open with Geany"?

In case of the first one: it is intended behaviour that a new Geany window is opened in that case, same as on non-Windows systems.

In case of the second one: that works for me with current GIT master. Could you try a nightly build (http://nightly.geany.org)?

@eht16 eht16 self-assigned this Sep 12, 2015

@CeruleanSky

This comment has been minimized.

Copy link
Author

commented Sep 12, 2015

They were not launched with the Open with Geany context.

They were both launched from separate command prompts with the same user credentials, and for a while every new geany opened up a new instance.

I retested the behavior and right now it stopped and is acting normal again.

Next time it occurs I'll try running windbg,on it if I can figure out some method that can give some insight on what went wrong.

I am going to close this ticket as intermittent behavior and thus would likely be very difficult to narrow down. I'll reoppen it if I obtain some better diagnostics.

@volcik

This comment has been minimized.

Copy link

commented Mar 5, 2019

Hello, I know it is old and closed issue, but the exact same thing started to happen again. I'm on 1.34.1 . Win10

When double clicked on any geany associated file (let's say txt), or when other tools "push" some files to external editor (mine is geany) every time a new instance pops-up. It started to behave like this Today without any errors or warnings. Important is that when double click on text file it used to open in 1/10 of blink of an eye. Now it takes about 2 seconds to open. I've tried to re-install already.

I've run it with verbose, but there is not enough to debug for me

geany-cmd

procexp of two running geanys

geanys

@eht16

This comment has been minimized.

Copy link
Member

commented Mar 25, 2019

Thanks for the detailed information.
The mutex isn't necessarily the source of the problem: it is only used to detect another instance. For communication between the existent and the new instance a TCP connection is used on port 49876 on 127.0.0.1. Over this TCP connection the new instance sends the filename or other actions to the existent instance.

Maybe you set up a firewall, running another service on port 49876 or anything else caused the TCP connection to break?

I'll check if we can add some more useful debug/error output in the relevant code.

eht16 added a commit to eht16/geany that referenced this issue Mar 25, 2019

Windows: Use SO_EXCLUSIVEADDRUSE flag for IPC socket
SO_REUSEADDR on Windows allows to bind to an already used port
without an error. This way we never notice if the port is already used.
So use the Windows special flag SO_EXCLUSIVEADDRUSE to ensure we receive
an error if the port is already used.

Part of geany#641.

eht16 added a commit to eht16/geany that referenced this issue Apr 7, 2019

Windows: Use SO_EXCLUSIVEADDRUSE flag for IPC socket
SO_REUSEADDR on Windows allows to bind to an already used port
without an error. This way we never notice if the port is already used.
So use the Windows special flag SO_EXCLUSIVEADDRUSE to ensure we receive
an error if the port is already used.

Part of geany#641.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.