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
77ab47b6
Commit
77ab47b6
authored
Sep 29, 2014
by
Vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support for some error codes
parent
75b0f3d2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
12 deletions
+45
-12
interface.c
interface.c
+12
-3
queries.c
queries.c
+33
-9
No files found.
interface.c
View file @
77ab47b6
...
...
@@ -1957,8 +1957,11 @@ void interpreter_ex (char *line UU, void *ex) {
if
(
op
==
ca_none
)
{
next_token
();
if
(
cur_token_end_str
)
{
int
z
;
for
(
z
=
0
;
z
<
count
;
z
++
)
{
fun
(
args_num
,
args
,
ex
);
}
}
break
;
}
...
...
@@ -1969,7 +1972,10 @@ void interpreter_ex (char *line UU, void *ex) {
}
else
{
args
[
args_num
].
flags
=
1
;
args
[
args_num
++
].
str
=
strndup
(
cur_token
,
cur_token_len
);
int
z
;
for
(
z
=
0
;
z
<
count
;
z
++
)
{
fun
(
args_num
,
args
,
ex
);
}
break
;
}
}
...
...
@@ -1978,7 +1984,10 @@ void interpreter_ex (char *line UU, void *ex) {
next_token
();
if
(
period
&&
cur_token_end_str
)
{
int
z
;
for
(
z
=
0
;
z
<
count
;
z
++
)
{
fun
(
args_num
,
args
,
ex
);
}
break
;
}
...
...
queries.c
View file @
77ab47b6
...
...
@@ -94,7 +94,7 @@ struct query *tglq_query_get (long long id) {
static
int
alarm_query
(
struct
query
*
q
)
{
assert
(
q
);
vlogprintf
(
E_DEBUG
,
"Alarm query %lld
\n
"
,
q
->
msg_id
);
vlogprintf
(
E_DEBUG
-
1
,
"Alarm query %lld
\n
"
,
q
->
msg_id
);
//q->ev.timeout = get_double_time () + QUERY_TIMEOUT;
//insert_event_timer (&q->ev);
...
...
@@ -118,7 +118,9 @@ static int alarm_query (struct query *q) {
tglmp_encrypt_send_message
(
q
->
session
->
c
,
packet_buffer
,
packet_ptr
-
packet_buffer
,
q
->
flags
&
QUERY_FORCE_SEND
);
}
else
{
q
->
flags
&=
~
QUERY_ACK_RECEIVED
;
if
(
tree_lookup_query
(
queries_tree
,
q
))
{
queries_tree
=
tree_delete_query
(
queries_tree
,
q
);
}
q
->
msg_id
=
tglmp_encrypt_send_message
(
q
->
session
->
c
,
q
->
data
,
q
->
data_len
,
(
q
->
flags
&
QUERY_FORCE_SEND
)
|
1
);
queries_tree
=
tree_insert_query
(
queries_tree
,
q
,
lrand48
());
q
->
session_id
=
q
->
session
->
session_id
;
...
...
@@ -219,15 +221,27 @@ void tglq_query_error (long long id) {
event_del
(
q
->
ev
);
}
queries_tree
=
tree_delete_query
(
queries_tree
,
q
);
if
(
q
->
methods
&&
q
->
methods
->
on_error
)
{
q
->
methods
->
on_error
(
q
,
error_code
,
error_len
,
error
);
int
res
=
0
;
if
(
q
->
methods
&&
q
->
methods
->
on_error
&&
error_code
!=
500
)
{
res
=
q
->
methods
->
on_error
(
q
,
error_code
,
error_len
,
error
);
}
else
{
vlogprintf
(
E_WARNING
,
"error for query #%lld: #%d :%.*s
\n
"
,
id
,
error_code
,
error_len
,
error
);
if
(
error_code
==
420
||
error_code
==
500
)
{
assert
(
!
strncmp
(
error
,
"FLOOD_WAIT_"
,
11
));
int
wait
=
atoll
(
error
+
11
);
q
->
flags
&=
~
QUERY_ACK_RECEIVED
;
static
struct
timeval
ptimeout
;
ptimeout
.
tv_sec
=
wait
;
event_add
(
q
->
ev
,
&
ptimeout
);
q
->
session_id
=
0
;
res
=
1
;
}
}
if
(
res
<=
0
)
{
tfree
(
q
->
data
,
q
->
data_len
*
4
);
event_free
(
q
->
ev
);
tfree
(
q
,
sizeof
(
*
q
));
}
}
tgl_state
.
active_queries
--
;
}
...
...
@@ -914,7 +928,17 @@ static int msg_send_on_answer (struct query *q UU) {
}
static
int
msg_send_on_error
(
struct
query
*
q
,
int
error_code
,
int
error_len
,
char
*
error
)
{
vlogprintf
(
E_WARNING
,
"error for query #%lld: #%d :%.*s
\n
"
,
q
->
msg_id
,
error_code
,
error_len
,
error
);
//vlogprintf (E_WARNING, "error for query #%lld: #%d :%.*s\n", q->msg_id, error_code, error_len, error);
if
(
error_code
==
420
)
{
assert
(
!
strncmp
(
error
,
"FLOOD_WAIT_"
,
11
));
int
wait
=
atoll
(
error
+
11
);
q
->
flags
&=
~
QUERY_ACK_RECEIVED
;
static
struct
timeval
ptimeout
;
ptimeout
.
tv_sec
=
wait
;
event_add
(
q
->
ev
,
&
ptimeout
);
q
->
session_id
=
0
;
return
1
;
}
long
long
x
=
*
(
long
long
*
)
q
->
extra
;
tfree
(
q
->
extra
,
8
);
struct
tgl_message
*
M
=
tgl_message_get
(
x
);
...
...
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