Skip to content

Commit f178dd5

Browse files
game_console: fix logs paging, fix test, change submodule path
1 parent 0bb1dfa commit f178dd5

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "services/game_console/hw/mbed-os"]
22
path = services/game_console/hw/mbed-os
3-
url = https://github.com/ARMmbed/mbed-os.git
4-
branch = tags/mbed-os-5.12.4
3+
url = git@github.com:HackerDom/mbed-os.git
4+
branch = hackerdom

services/game_console/server/log.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@ char* GetPage(uint32_t pageIdx, uint32_t& pageSize)
7171
std::mutex GMutex;
7272
uint32_t pagesNum = (GLog.size() + kPageSize - 1) / kPageSize;
7373
if(pageIdx == ~0u)
74-
pageIdx = pagesNum - 1;
75-
if(pageIdx >= pagesNum)
74+
pageIdx = pagesNum;
75+
if(pageIdx == 0 || pageIdx > pagesNum)
7676
{
7777
pageSize = 0;
7878
return nullptr;
7979
}
8080

81+
pageIdx--;
82+
8183
uint32_t firstLineIdx = pageIdx * kPageSize;
8284
uint32_t lastLineIdx = firstLineIdx + kPageSize - 1;
8385
if(lastLineIdx >= GLog.size())

services/game_console/server_test/cs_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
int main(int argc, char* argv[])
1313
{
14-
if(argc < 3)
14+
if(argc < 2)
1515
return -1;
1616

1717
sockaddr_in addr;
1818
addr.sin_family = AF_INET;
1919
inet_aton(argv[1], &addr.sin_addr);
20-
addr.sin_port = htons(atoi(argv[2]));
20+
addr.sin_port = htons(8002);
2121

2222
int sock = -1;
2323

services/game_console/server_test/test.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import time
99
import random
1010
import string
11+
import time
1112

1213
serverAddr = argv[1]
1314
userName = argv[2]
@@ -28,6 +29,8 @@
2829
notifySock.connect((serverAddr, 8001))
2930
notifySock.send(authKeyRaw)
3031

32+
lastNotificationTime = 0
33+
3134
while True:
3235
try:
3336
data = notifySock.recv(16, socket.MSG_DONTWAIT)
@@ -41,16 +44,20 @@
4144
print("Notifications available: %u" % notificationsNum)
4245
notifySock.send(data)
4346

44-
url = 'http://%s/notification?auth=%x' % (serverAddr, authKey)
45-
r = requests.get(url)
46-
if r.status_code != 200:
47-
printf("Get notification failed")
48-
if len(r.content) > 0:
49-
print("Got notification")
47+
for i in range(0, notificationsNum):
48+
url = 'http://%s/notification?auth=%x' % (serverAddr, authKey)
49+
r = requests.get(url)
50+
if r.status_code != 200:
51+
printf("Get notification failed")
52+
if len(r.content) > 0:
53+
print("Got notification")
5054
except:
5155
pass
5256

5357
method = int(random.uniform(0, 6))
58+
if method == 5 and time.time() - lastNotificationTime < 5:
59+
continue
60+
5461
if method == 0:
5562
url = 'http://%s/auth?u=%s&p=%s' % (serverAddr, userName, password)
5663
if method == 1:
@@ -79,6 +86,8 @@
7986
print(url)
8087
requests.post(url=url, data=notification, headers={'Content-Type': 'application/octet-stream'})
8188

89+
lastNotificationTime = time.time()
90+
8291
if method != 5:
8392
print(url)
8493
r = requests.get(url)

0 commit comments

Comments
 (0)