Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
17f9a63b
Commit
17f9a63b
authored
Feb 13, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
81049e5d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
18 deletions
+64
-18
wcfs/client/wcfs.cpp
wcfs/client/wcfs.cpp
+17
-17
wcfs/client/wcfs_misc.cpp
wcfs/client/wcfs_misc.cpp
+38
-1
wcfs/client/wcfs_misc.h
wcfs/client/wcfs_misc.h
+9
-0
No files found.
wcfs/client/wcfs.cpp
View file @
17f9a63b
...
...
@@ -163,7 +163,23 @@ error _Conn::_pinner(context::Context ctx) {
_Conn
&
wconn
=
*
this
;
xerr
::
Contextf
E
(
"pinner"
);
// NOTE pinner error goes to Conn::close who has its own context
for
(
int
i
=
0
;
i
<
10
;
i
++
)
xlog
::
Fatalf
(
"Hello from pinner! %d %s"
,
i
,
"qqq zzz"
);
error
err
=
wconn
.
__pinner
(
ctx
);
err
=
E
(
err
);
// if pinner fails, wcfs will kill us.
// log pinner error so the error is not hidden.
// print to stderr as well as by default log does not print to there.
// XXX also catch panic/exc ?
if
(
!
(
err
==
nil
||
errors
::
Is
(
err
,
context
::
canceled
)))
{
// canceled = .close asks pinner to stop
xlog
::
Fatalf
(
"CRITICAL: %s"
,
v
(
err
));
xlog
::
Fatalf
(
"CRITICAL: wcfs server will likely kill us soon."
);
fprintf
(
stderr
,
"CRITICAL: %s
\n
"
,
v
(
err
));
fprintf
(
stderr
,
"CRITICAL: wcfs server will likely kill us soon.
\n
"
);
}
// mark the connection non-operational if the pinner fails
wconn
.
_downMu
.
lock
();
...
...
@@ -173,28 +189,12 @@ error _Conn::_pinner(context::Context ctx) {
}
wconn
.
_downMu
.
unlock
();
return
E
(
err
)
;
return
err
;
}
error
_Conn
::
__pinner
(
context
::
Context
ctx
)
{
_Conn
&
wconn
=
*
this
;
// XXX panic/exc -> log.CRITICAL
#if 0
// if pinner fails, wcfs will kill us.
// log pinner exception so the error is not hidden.
// print to stderr as well as by default log does not print to there.
def _():
exc = sys.exc_info()[1]
if exc in (None, context.canceled): # canceled = .close asks pinner to stop
return
log.critical('pinner failed:', exc_info=1)
print('CRITICAL: pinner failed:', file=sys.stderr)
traceback.print_exc(file=sys.stderr)
print('\nCRITICAL: wcfs server will likely kill us soon.', file=sys.stderr)
defer(_)
#endif
PinReq
req
;
error
err
;
...
...
wcfs/client/wcfs_misc.cpp
View file @
17f9a63b
...
...
@@ -241,6 +241,43 @@ error Contextf::operator() (error err) const {
}
// xerr::
#include <golang/time.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/syscall.h>
// xlog::
namespace
xlog
{
void
__Logf
(
const
char
*
file
,
int
line
,
char
level
,
const
char
*
format
,
...)
{
double
t
=
time
::
now
();
time_t
t_int
=
time_t
(
t
);
struct
tm
tm_loc
;
localtime_r
(
&
t_int
,
&
tm_loc
);
char
t_buf
[
32
];
strftime
(
t_buf
,
sizeof
(
t_buf
),
"%m%d %H:%M:%S"
,
&
tm_loc
);
int
t_us
=
int
((
t
-
t_int
)
*
1E6
);
pid_t
tid
=
syscall
(
SYS_gettid
);
string
prefix
=
fmt
::
sprintf
(
"%c%s.%06d %d %s:%d] "
,
level
,
t_buf
,
t_us
,
tid
,
file
,
line
);
// XXX better to emit prefix and msg in one go.
fprintf
(
stderr
,
"%s"
,
v
(
prefix
));
va_list
argp
;
va_start
(
argp
,
format
);
vfprintf
(
stderr
,
format
,
argp
);
va_end
(
argp
);
fprintf
(
stderr
,
"
\n
"
);
}
}
// xlog
// wcfs::
namespace
wcfs
{
...
...
@@ -252,7 +289,7 @@ static string h016(uint64_t v) { return fmt::sprintf("%016lx", v); }
template
<
>
string
v_
(
zodb
::
Tid
tid
)
{
return
h016
(
tid
);
}
//template<> string v_(zodb::Oid oid) { return h016(oid); }
// XXX Tid and Oid are typedefs for uint64_t and C++ reduces template
// specializations to theunderlying type. This providing specialization for
// specializations to the
underlying type. This providing specialization for
// both Tid and Oid results in "multiple definition" error.
}
// wcfs::
wcfs/client/wcfs_misc.h
View file @
17f9a63b
...
...
@@ -168,6 +168,15 @@ public:
}
// xerr::
// xlog::
namespace
xlog
{
#define Fatalf(format, ...) __Logf(__FILE__, __LINE__, 'F', format, ##__VA_ARGS__)
void
__Logf
(
const
char
*
file
,
int
line
,
char
level
,
const
char
*
format
,
...);
}
// xlog::
// wcfs::
namespace
wcfs
{
...
...
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