Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
1602a33b
Commit
1602a33b
authored
Aug 27, 2014
by
vvaltman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed work with updates
parent
91869427
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
12 deletions
+30
-12
binlog.c
binlog.c
+13
-1
loop.c
loop.c
+13
-7
queries.c
queries.c
+1
-1
tgl.h
tgl.h
+1
-1
updates.c
updates.c
+2
-2
No files found.
binlog.c
View file @
1602a33b
...
...
@@ -53,6 +53,7 @@ static int binlog_buffer[BINLOG_BUFFER_SIZE];
static
int
*
rptr
;
static
int
*
wptr
;
static
int
binlog_fd
;
static
int
in_replay_log
;
// should be used ONLY for DEBUG
#define MAX_LOG_EVENT_SIZE (1 << 17)
...
...
@@ -140,13 +141,15 @@ static int fetch_comb_binlog_set_dh_params (void *extra) {
static
int
fetch_comb_binlog_set_pts
(
void
*
extra
)
{
int
new_pts
=
fetch_int
();
assert
(
new_pts
>=
tgl_state
.
pts
);
vlogprintf
(
E_DEBUG
-
1
+
2
*
in_replay_log
,
"pts %d=>%d
\n
"
,
tgl_state
.
pts
,
new_pts
);
tgl_state
.
pts
=
new_pts
;
return
0
;
}
static
int
fetch_comb_binlog_set_qts
(
void
*
extra
)
{
int
new_qts
=
fetch_int
();
//assert (new_qts >= qts);
assert
(
new_qts
>=
tgl_state
.
qts
);
vlogprintf
(
E_DEBUG
-
1
+
2
*
in_replay_log
,
"qts %d=>%d
\n
"
,
tgl_state
.
qts
,
new_qts
);
tgl_state
.
qts
=
new_qts
;
return
0
;
}
...
...
@@ -164,6 +167,7 @@ static int fetch_comb_binlog_set_seq (void *extra) {
vlogprintf
(
E_ERROR
,
"Error: old_seq = %d, new_seq = %d
\n
"
,
tgl_state
.
seq
,
new_seq
);
}
assert
(
new_seq
>=
tgl_state
.
seq
);
vlogprintf
(
E_DEBUG
-
1
+
2
*
in_replay_log
,
"seq %d=>%d
\n
"
,
tgl_state
.
seq
,
new_seq
);
tgl_state
.
seq
=
new_seq
;
return
0
;
}
...
...
@@ -1087,6 +1091,7 @@ static int fetch_comb_binlog_msg_seq_update (void *extra) {
struct
tgl_message
*
M
=
tgl_message_get
(
fetch_long
());
assert
(
M
);
tgl_state
.
seq
++
;
vlogprintf
(
E_DEBUG
-
1
+
2
*
in_replay_log
,
"seq %d=>%d
\n
"
,
tgl_state
.
seq
-
1
,
tgl_state
.
seq
);
if
(
tgl_state
.
callback
.
msg_receive
)
{
tgl_state
.
callback
.
msg_receive
(
M
);
...
...
@@ -1234,6 +1239,7 @@ void tgl_replay_log (void) {
exit
(
2
);
}
int
end
=
0
;
in_replay_log
=
1
;
while
(
1
)
{
if
(
!
end
&&
wptr
-
rptr
<
MAX_LOG_EVENT_SIZE
/
4
)
{
if
(
wptr
==
rptr
)
{
...
...
@@ -1259,6 +1265,7 @@ void tgl_replay_log (void) {
if
(
wptr
==
rptr
)
{
break
;
}
replay_log_event
();
}
in_replay_log
=
0
;
close
(
fd
);
}
...
...
@@ -1573,6 +1580,7 @@ void bl_do_encr_chat_init (int id, int user_id, unsigned char random[], unsigned
void
bl_do_set_pts
(
int
pts
)
{
if
(
tgl_state
.
locks
&
TGL_LOCK_DIFF
)
{
return
;
}
if
(
pts
==
tgl_state
.
pts
)
{
return
;
}
int
*
ev
=
alloc_log_event
(
8
);
ev
[
0
]
=
CODE_binlog_set_pts
;
ev
[
1
]
=
pts
;
...
...
@@ -1580,6 +1588,8 @@ void bl_do_set_pts (int pts) {
}
void
bl_do_set_qts
(
int
qts
)
{
if
(
tgl_state
.
locks
&
TGL_LOCK_DIFF
)
{
return
;
}
if
(
qts
==
tgl_state
.
qts
)
{
return
;
}
int
*
ev
=
alloc_log_event
(
8
);
ev
[
0
]
=
CODE_binlog_set_qts
;
ev
[
1
]
=
qts
;
...
...
@@ -1588,6 +1598,7 @@ void bl_do_set_qts (int qts) {
void
bl_do_set_date
(
int
date
)
{
if
(
tgl_state
.
locks
&
TGL_LOCK_DIFF
)
{
return
;
}
if
(
date
==
tgl_state
.
date
)
{
return
;
}
int
*
ev
=
alloc_log_event
(
8
);
ev
[
0
]
=
CODE_binlog_set_date
;
ev
[
1
]
=
date
;
...
...
@@ -1596,6 +1607,7 @@ void bl_do_set_date (int date) {
void
bl_do_set_seq
(
int
seq
)
{
if
(
tgl_state
.
locks
&
TGL_LOCK_DIFF
)
{
return
;
}
if
(
seq
==
tgl_state
.
seq
)
{
return
;
}
int
*
ev
=
alloc_log_event
(
8
);
ev
[
0
]
=
CODE_binlog_set_seq
;
ev
[
1
]
=
seq
;
...
...
loop.c
View file @
1602a33b
...
...
@@ -138,7 +138,7 @@ static void stdin_read_callback_line (evutil_socket_t fd, short what, void *arg)
void
net_loop
(
int
flags
,
int
(
*
is_end
)(
void
))
{
delete_stdin_event
=
0
;
if
(
verbosity
)
{
if
(
verbosity
>=
E_DEBUG
)
{
logprintf
(
"Starting netloop
\n
"
);
}
struct
event
*
ev
=
0
;
...
...
@@ -184,7 +184,7 @@ void net_loop (int flags, int (*is_end)(void)) {
event_free
(
ev
);
}
if
(
verbosity
)
{
if
(
verbosity
>=
E_DEBUG
)
{
logprintf
(
"End of netloop
\n
"
);
}
}
...
...
@@ -474,9 +474,13 @@ int loop (void) {
if
(
binlog_enabled
)
{
double
t
=
tglt_get_double_time
();
if
(
verbosity
>=
E_DEBUG
)
{
logprintf
(
"replay log start
\n
"
);
}
tgl_replay_log
();
if
(
verbosity
>=
E_DEBUG
)
{
logprintf
(
"replay log end in %lf seconds
\n
"
,
tglt_get_double_time
()
-
t
);
}
tgl_reopen_binlog_for_writing
();
}
else
{
read_auth_file
();
...
...
@@ -497,7 +501,7 @@ int loop (void) {
tgl_do_help_get_config
(
on_get_config
,
0
);
net_loop
(
0
,
got_config
);
if
(
verbosity
)
{
if
(
verbosity
>=
E_DEBUG
)
{
logprintf
(
"DC_info: %d new DC got
\n
"
,
new_dc_num
);
}
...
...
@@ -525,7 +529,9 @@ int loop (void) {
tgl_do_send_code
(
default_username
,
sign_in_callback
,
0
);
net_loop
(
0
,
sent_code
);
if
(
verbosity
>=
E_DEBUG
)
{
logprintf
(
"%s
\n
"
,
should_register
?
"phone not registered"
:
"phone registered"
);
}
if
(
!
should_register
)
{
char
*
code
=
0
;
size_t
size
=
0
;
...
...
queries.c
View file @
1602a33b
...
...
@@ -2917,7 +2917,7 @@ void tgl_do_get_difference (int sync_from_start, void (*callback)(void *callback
tgl_do_insert_header
();
if
(
tgl_state
.
seq
>
0
||
sync_from_start
)
{
if
(
tgl_state
.
pts
==
0
)
{
tgl_state
.
pts
=
1
;
}
if
(
tgl_state
.
qts
==
0
)
{
tgl_state
.
qts
=
1
;
}
//
if (tgl_state.qts == 0) { tgl_state.qts = 1; }
if
(
tgl_state
.
date
==
0
)
{
tgl_state
.
date
=
1
;
}
out_int
(
CODE_updates_get_difference
);
out_int
(
tgl_state
.
pts
);
...
...
tgl.h
View file @
1602a33b
...
...
@@ -110,7 +110,7 @@ struct tgl_net_methods {
#define E_ERROR 0
#define E_WARNING 1
#define E_NOTICE 2
#define E_DEBUG
3
#define E_DEBUG
6
#define TGL_LOCK_DIFF 1
...
...
updates.c
View file @
1602a33b
...
...
@@ -29,13 +29,13 @@
void
tglu_fetch_pts
(
void
)
{
int
p
=
fetch_int
();
if
(
p
<=
tgl_state
.
pts
)
{
return
;
}
bl_do_set_pts
(
tgl_state
.
pts
);
bl_do_set_pts
(
p
);
}
void
tglu_fetch_qts
(
void
)
{
int
p
=
fetch_int
();
if
(
p
<=
tgl_state
.
qts
)
{
return
;
}
bl_do_set_qts
(
tgl_state
.
qts
);
bl_do_set_qts
(
p
);
}
void
tglu_fetch_date
(
void
)
{
...
...
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