Skip to content

Commit 1ac2fde

Browse files
committed
Use another unix domain socket abstract name when in debug mode
1 parent f14d6f0 commit 1ac2fde

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

config/keys

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ nmap ]] click-next-page
5656
fmap <Esc> hide-hints
5757
imap <Esc> normal
5858

59-
cmap <C-r> delete-selected-bookmark
59+
cmap <C-D> delete-selected-bookmark
6060
cmap <C-n> complete-next
6161
cmap <C-p> complete-previous
6262

src/message_server.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use tokio_io::io::WriteHalf;
4444
use tokio_serde_bincode::{ReadBincode, WriteBincode};
4545
use webkit2gtk::WebContext;
4646

47-
use titanium_common::{ExtensionId, InnerMessage, Message, PageId, PATH};
47+
use titanium_common::{ExtensionId, InnerMessage, Message, PageId, SOCKET_NAME};
4848
use titanium_common::InnerMessage::{Id, Open};
4949

5050
use app::{self, App};
@@ -200,7 +200,7 @@ impl MessageServer {
200200
// TODO: should be removed on Drop instead (or the connection close should remove it
201201
// automatically?).
202202
let listener =
203-
match UnixListener::bind_abstract(PATH, &cx) {
203+
match UnixListener::bind_abstract(SOCKET_NAME, &cx) {
204204
Err(nix::Error::Sys(nix::Errno::EADDRINUSE)) => {
205205
// A titanium process is already running, so we send the URL to this process so
206206
// that it can open a new window.
@@ -357,7 +357,7 @@ fn dialog_and_exit(message: &str) -> ! {
357357

358358
fn send_url_to_existing_process(url: &[String]) -> Result<()> {
359359
let cx = MainContext::default(|cx| cx.clone());
360-
let stream = UnixStream::connect_abstract(PATH, &cx)?;
360+
let stream = UnixStream::connect_abstract(SOCKET_NAME, &cx)?;
361361

362362
let cx = MainContext::default(|cx| cx.clone());
363363
let ex = Executor::new();

titanium-common/src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ extern crate serde_derive;
3636
/// The mark that goes to the last position after a jump.
3737
pub const LAST_MARK: u8 = b'\'';
3838

39-
// TODO: put in the home directory.
40-
/// The path to the unix domain socket.
41-
pub const PATH: &[u8] = b"titanium-server";
39+
/// The abstract name to the unix domain socket.
40+
#[cfg(not(debug_assertions))]
41+
pub const SOCKET_NAME: &[u8] = b"titanium-server";
42+
/// A different name is used in debug mode for easier debugging.
43+
#[cfg(debug_assertions)]
44+
pub const SOCKET_NAME: &[u8] = b"titanium-server-debug";
4245

4346
#[doc(hidden)]
4447
pub type ExtensionId = u64;

titanium-web-extension/src/message_client.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use webkit2gtk_webextension::{
3838
WebPageExt,
3939
};
4040

41-
use titanium_common::{ExtensionId, Message, PageId, PATH};
41+
use titanium_common::{ExtensionId, Message, PageId, SOCKET_NAME};
4242
use titanium_common::InnerMessage;
4343
use titanium_common::InnerMessage::*;
4444

@@ -154,7 +154,7 @@ impl UpdateNew for MessageClient {
154154
impl MessageClient {
155155
pub fn new() -> nix::Result<EventStream<<Self as Update>::Msg>> {
156156
let cx = MainContext::default(|cx| cx.clone());
157-
let stream = UnixStream::connect_abstract(PATH, &cx)?;
157+
let stream = UnixStream::connect_abstract(SOCKET_NAME, &cx)?;
158158
Ok(execute::<MessageClient>(stream))
159159
}
160160

0 commit comments

Comments
 (0)