Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
88
Issues
88
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
c8b41d5e
Commit
c8b41d5e
authored
Feb 08, 2014
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Be verbose about IRC server connection failures, and handle them properly
parent
de7b3503
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
11 deletions
+20
-11
src/irc/irc_client.cpp
src/irc/irc_client.cpp
+6
-1
src/network/socket_handler.cpp
src/network/socket_handler.cpp
+11
-8
src/network/socket_handler.hpp
src/network/socket_handler.hpp
+2
-1
src/xmpp/xmpp_component.cpp
src/xmpp/xmpp_component.cpp
+1
-1
No files found.
src/irc/irc_client.cpp
View file @
c8b41d5e
...
...
@@ -27,7 +27,12 @@ IrcClient::~IrcClient()
void
IrcClient
::
start
()
{
this
->
connect
(
this
->
hostname
,
"6667"
);
this
->
bridge
->
send_xmpp_message
(
this
->
hostname
,
""
,
std
::
string
(
"Connecting to "
)
+
this
->
hostname
+
":"
+
"6667"
);
std
::
pair
<
bool
,
std
::
string
>
res
=
this
->
connect
(
this
->
hostname
,
"6667"
);
if
(
!
res
.
first
)
this
->
bridge
->
send_xmpp_message
(
this
->
hostname
,
""
,
std
::
string
(
"Connection failed: "
)
+
res
.
second
);
}
void
IrcClient
::
on_connected
()
...
...
src/network/socket_handler.cpp
View file @
c8b41d5e
...
...
@@ -23,7 +23,7 @@ SocketHandler::SocketHandler():
throw
std
::
runtime_error
(
"Could not create socket"
);
}
bool
SocketHandler
::
connect
(
const
std
::
string
&
address
,
const
std
::
string
&
port
)
std
::
pair
<
bool
,
std
::
string
>
SocketHandler
::
connect
(
const
std
::
string
&
address
,
const
std
::
string
&
port
)
{
log_info
(
"Trying to connect to "
<<
address
<<
":"
<<
port
);
struct
addrinfo
hints
;
...
...
@@ -35,15 +35,18 @@ bool SocketHandler::connect(const std::string& address, const std::string& port)
struct
addrinfo
*
addr_res
;
const
int
res
=
::
getaddrinfo
(
address
.
c_str
(),
port
.
c_str
(),
&
hints
,
&
addr_res
);
// Make sure the alloced structure is always freed at the end of the
// function
utils
::
ScopeGuard
sg
([
&
addr_res
](){
freeaddrinfo
(
addr_res
);
});
if
(
res
!=
0
)
{
perror
(
"getaddrinfo"
);
throw
std
::
runtime_error
(
"getaddrinfo failed"
);
log_warning
(
std
::
string
(
"getaddrinfo failed: "
)
+
gai_strerror
(
res
));
this
->
close
();
return
std
::
make_pair
(
false
,
gai_strerror
(
res
));
}
// Make sure the alloced structure is always freed at the end of the
// function
utils
::
ScopeGuard
sg
([
&
addr_res
](){
freeaddrinfo
(
addr_res
);
});
for
(
struct
addrinfo
*
rp
=
addr_res
;
rp
;
rp
=
rp
->
ai_next
)
{
if
(
::
connect
(
this
->
socket
,
rp
->
ai_addr
,
rp
->
ai_addrlen
)
==
0
)
...
...
@@ -51,14 +54,14 @@ bool SocketHandler::connect(const std::string& address, const std::string& port)
log_info
(
"Connection success."
);
this
->
connected
=
true
;
this
->
on_connected
();
return
true
;
return
std
::
make_pair
(
true
,
""
)
;
}
log_info
(
"Connection failed:"
);
perror
(
"connect"
);
}
log_error
(
"All connection attempts failed."
);
this
->
close
();
return
false
;
return
std
::
make_pair
(
false
,
""
)
;
}
void
SocketHandler
::
set_poller
(
Poller
*
poller
)
...
...
src/network/socket_handler.hpp
View file @
c8b41d5e
...
...
@@ -2,6 +2,7 @@
# define SOCKET_HANDLER_INCLUDED
#include <string>
#include <utility>
typedef
int
socket_t
;
...
...
@@ -21,7 +22,7 @@ public:
/**
* Connect to the remote server, and call on_connected() if this succeeds
*/
bool
connect
(
const
std
::
string
&
address
,
const
std
::
string
&
port
);
std
::
pair
<
bool
,
std
::
string
>
connect
(
const
std
::
string
&
address
,
const
std
::
string
&
port
);
/**
* Set the pointer to the given Poller, to communicate with it.
*/
...
...
src/xmpp/xmpp_component.cpp
View file @
c8b41d5e
...
...
@@ -49,7 +49,7 @@ XmppComponent::~XmppComponent()
bool
XmppComponent
::
start
()
{
return
this
->
connect
(
"127.0.0.1"
,
"5347"
);
return
this
->
connect
(
"127.0.0.1"
,
"5347"
)
.
first
;
}
bool
XmppComponent
::
is_document_open
()
const
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment