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
12b9882a
Commit
12b9882a
authored
Nov 30, 2013
by
Vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed binlog problems. Set lock on binlog
parent
8bc40adf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
14 deletions
+80
-14
binlog.c
binlog.c
+10
-4
config.sample
config.sample
+52
-8
main.c
main.c
+5
-1
queries.c
queries.c
+13
-1
No files found.
binlog.c
View file @
12b9882a
#include <unistd.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <stdlib.h>
#include <stdlib.h>
#include <fcntl.h>
#include <fcntl.h>
#include <errno.h>
#include <errno.h>
...
@@ -1024,7 +1025,7 @@ void replay_log_event (void) {
...
@@ -1024,7 +1025,7 @@ void replay_log_event (void) {
rptr
=
in_ptr
;
rptr
=
in_ptr
;
break
;
break
;
default:
default:
logprintf
(
"Unknown logevent [0x%08x] 0x%08x [0x%08x]
\n
"
,
*
(
rptr
-
1
),
op
,
*
(
rptr
+
1
)
);
logprintf
(
"Unknown logevent [0x%08x] 0x%08x [0x%08x]
at %lld
\n
"
,
*
(
rptr
-
1
),
op
,
*
(
rptr
+
1
),
binlog_pos
);
assert
(
0
);
assert
(
0
);
}
}
...
@@ -1075,8 +1076,8 @@ void replay_log (void) {
...
@@ -1075,8 +1076,8 @@ void replay_log (void) {
}
else
{
}
else
{
int
x
=
wptr
-
rptr
;
int
x
=
wptr
-
rptr
;
memcpy
(
binlog_buffer
,
rptr
,
4
*
x
);
memcpy
(
binlog_buffer
,
rptr
,
4
*
x
);
wptr
-=
x
;
wptr
-=
(
rptr
-
binlog_buffer
)
;
rptr
-=
x
;
rptr
=
binlog_buffer
;
}
}
int
l
=
(
binlog_buffer
+
BINLOG_BUFFER_SIZE
-
wptr
)
*
4
;
int
l
=
(
binlog_buffer
+
BINLOG_BUFFER_SIZE
-
wptr
)
*
4
;
int
k
=
read
(
fd
,
wptr
,
l
);
int
k
=
read
(
fd
,
wptr
,
l
);
...
@@ -1103,7 +1104,12 @@ void write_binlog (void) {
...
@@ -1103,7 +1104,12 @@ void write_binlog (void) {
perror
(
"binlog open"
);
perror
(
"binlog open"
);
exit
(
2
);
exit
(
2
);
}
}
lseek
(
binlog_fd
,
0
,
SEEK_END
);
assert
(
lseek
(
binlog_fd
,
binlog_pos
,
SEEK_SET
)
==
binlog_pos
);
if
(
flock
(
binlog_fd
,
LOCK_EX
|
LOCK_NB
)
<
0
)
{
perror
(
"get lock"
);
exit
(
2
);
}
}
}
void
add_log_event
(
const
int
*
data
,
int
len
)
{
void
add_log_event
(
const
int
*
data
,
int
len
)
{
...
...
config.sample
View file @
12b9882a
# This is
my real config
# This is
an empty config file
# Feel free to
edit it
# Feel free to
put something here
default_profile = "
tele2
";
default_profile = "
binlog
";
mts = {
test_dc1 = {
config_directory = ".telegram/test_dc1";
test = true;
msg_num = true;
binlog_enabled = true;
};
binlog = {
config_directory = ".telegram/binlog";
test = false;
test = false;
config_directory = ".telegram/mts";
msg_num = true;
msg_num = true;
binlog_enabled = true;
log_level = 2;
};
};
tele2 = {
binlog_mts = {
config_directory = ".telegram/binlog_mts";
test = false;
msg_num = true;
binlog_enabled = true;
log_level = 2;
};
mega = {
config_directory = ".telegram/mega";
test = false;
msg_num = true;
binlog_enabled = true;
log_level = 2;
};
new = {
config_directory = ".telegram/new";
test = false;
msg_num = true;
};
production = {
config_directory = ".telegram/production";
test = false;
test = false;
config_directory = ".telegram/tele2";
msg_num = true;
msg_num = true;
};
};
test = {
test = {
test = true;
config_directory = ".telegram/test";
config_directory = ".telegram/test";
test = true;
msg_num = true;
};
test1 = {
config_directory = ".telegram/test1";
msg_num = true;
binlog_enabled = true;
};
test2 = {
config_directory = ".telegram/test2";
msg_num = true;
msg_num = true;
binlog_enabled = true;
};
};
main.c
View file @
12b9882a
...
@@ -77,6 +77,7 @@ char *config_directory;
...
@@ -77,6 +77,7 @@ char *config_directory;
char
*
binlog_file_name
;
char
*
binlog_file_name
;
int
binlog_enabled
;
int
binlog_enabled
;
extern
int
log_level
;
extern
int
log_level
;
int
sync_from_start
;
void
set_default_username
(
const
char
*
s
)
{
void
set_default_username
(
const
char
*
s
)
{
if
(
default_username
)
{
if
(
default_username
)
{
...
@@ -315,7 +316,7 @@ extern int default_dc_num;
...
@@ -315,7 +316,7 @@ extern int default_dc_num;
int
register_mode
;
int
register_mode
;
void
args_parse
(
int
argc
,
char
**
argv
)
{
void
args_parse
(
int
argc
,
char
**
argv
)
{
int
opt
=
0
;
int
opt
=
0
;
while
((
opt
=
getopt
(
argc
,
argv
,
"u:hk:vn:Nc:p:l:R"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"u:hk:vn:Nc:p:l:R
f
"
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
case
'u'
:
case
'u'
:
set_default_username
(
optarg
);
set_default_username
(
optarg
);
...
@@ -342,6 +343,9 @@ void args_parse (int argc, char **argv) {
...
@@ -342,6 +343,9 @@ void args_parse (int argc, char **argv) {
case
'R'
:
case
'R'
:
register_mode
=
1
;
register_mode
=
1
;
break
;
break
;
case
'f'
:
sync_from_start
=
1
;
break
;
case
'h'
:
case
'h'
:
default:
default:
usage
();
usage
();
...
...
queries.c
View file @
12b9882a
...
@@ -64,6 +64,7 @@ long long cur_downloading_bytes;
...
@@ -64,6 +64,7 @@ long long cur_downloading_bytes;
long
long
cur_downloaded_bytes
;
long
long
cur_downloaded_bytes
;
extern
int
binlog_enabled
;
extern
int
binlog_enabled
;
extern
int
sync_from_start
;
void
out_peer_id
(
peer_id_t
id
);
void
out_peer_id
(
peer_id_t
id
);
#define QUERY_TIMEOUT 6.0
#define QUERY_TIMEOUT 6.0
...
@@ -2218,6 +2219,14 @@ BN_CTX *ctx;
...
@@ -2218,6 +2219,14 @@ BN_CTX *ctx;
void
do_send_accept_encr_chat
(
struct
secret_chat
*
E
,
unsigned
char
*
random
)
{
void
do_send_accept_encr_chat
(
struct
secret_chat
*
E
,
unsigned
char
*
random
)
{
int
i
;
int
i
;
int
ok
=
0
;
for
(
i
=
0
;
i
<
64
;
i
++
)
{
if
(
E
->
key
[
i
])
{
ok
=
1
;
break
;
}
}
if
(
ok
)
{
return
;
}
// Already generated key for this chat
for
(
i
=
0
;
i
<
64
;
i
++
)
{
for
(
i
=
0
;
i
<
64
;
i
++
)
{
*
(((
int
*
)
random
)
+
i
)
^=
mrand48
();
*
(((
int
*
)
random
)
+
i
)
^=
mrand48
();
}
}
...
@@ -2521,7 +2530,10 @@ void do_get_difference (void) {
...
@@ -2521,7 +2530,10 @@ void do_get_difference (void) {
difference_got
=
0
;
difference_got
=
0
;
clear_packet
();
clear_packet
();
do_insert_header
();
do_insert_header
();
if
(
seq
>
0
)
{
if
(
seq
>
0
||
sync_from_start
)
{
if
(
pts
==
0
)
{
pts
=
1
;
}
if
(
qts
==
0
)
{
qts
=
1
;
}
if
(
last_date
==
0
)
{
last_date
=
1
;
}
out_int
(
CODE_updates_get_difference
);
out_int
(
CODE_updates_get_difference
);
out_int
(
pts
);
out_int
(
pts
);
out_int
(
last_date
);
out_int
(
last_date
);
...
...
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