|
@@ -195,7 +195,7 @@ static int get_users(char *p, int size) {
|
|
|
int do_user_login(int fd, struct vcc_request *req) {
|
|
int do_user_login(int fd, struct vcc_request *req) {
|
|
|
struct vcc_request *out;
|
|
struct vcc_request *out;
|
|
|
char right_passwd[MSG_SIZE];
|
|
char right_passwd[MSG_SIZE];
|
|
|
- const static char join_msg[] = {"%s logged in. now there are %d users. \n"};
|
|
|
|
|
|
|
+ const static char *join_msg = "%s logged in. now there are %d users. \n";
|
|
|
char *t;
|
|
char *t;
|
|
|
|
|
|
|
|
if (unlikely(!(out = malloc(sizeof(struct vcc_request))))) {
|
|
if (unlikely(!(out = malloc(sizeof(struct vcc_request))))) {
|
|
@@ -220,14 +220,16 @@ int do_user_login(int fd, struct vcc_request *req) {
|
|
|
|
|
|
|
|
out->uid = htonl(1);
|
|
out->uid = htonl(1);
|
|
|
|
|
|
|
|
- if (unlikely(!(t = malloc(sizeof(join_msg))))) {
|
|
|
|
|
|
|
+ if (unlikely(!(t = malloc(128)))) {
|
|
|
vcc_log("*** malloc() failed\n");
|
|
vcc_log("*** malloc() failed\n");
|
|
|
|
|
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
vcc_send_req(find_connection(fd), out);
|
|
vcc_send_req(find_connection(fd), out);
|
|
|
- sprintf(t, join_msg, req->usrname, ++nusers);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /* nusers incs when it connects */
|
|
|
|
|
+ sprintf(t, join_msg, req->usrname, nusers);
|
|
|
|
|
|
|
|
vcc_message_broadcast(t, "system", 0);
|
|
vcc_message_broadcast(t, "system", 0);
|
|
|
|
|
|