[mw-devel] [Git][arthur/mw][master] Store messages after processing

Justin Mitchell arthur at sucs.org
Wed Nov 15 11:46:39 GMT 2017


You don't assign a serial number to the message until after you have
sent it, this is wrong.
I know the clients dont currently make use of the serial number but
they are supposed to and it really should be set at the first
opportunity.


On Wed, 2017-11-15 at 02:57 +0000, Andrew Price wrote:
> 
> Andrew Price pushed to branch master
> at Justin Mitchell / mw
> 
> 
> Commits:
> 
> 
> 
> 5e203b86
> 
> by Andrew Price
> at 2017-11-15T02:49:10+00:00
> 
> Store messages after processing
> 
> Move the store_message() call to after the apply_gag()ing and message
> routing has been done. That way the message will still be replayed
> with
> a gag applied after a server restart.
> 
> 
> 
> 1 changed file:
> 
> 
> 
> src/server/servsock.c
> 
> 
> 
> Changes:
> 
> src/server/servsock.c
> 
> 
> 
> ...
> ...
> @@ -359,10 +359,6 @@ void process_msg(ipc_connection_t *conn,
> ipc_message_t *msg)
> 
> 
> 
> 359
> 
> 
> 359
> 
> 
>  	 *    all below this point are intended to be retransmitted
> 
> 
> 
> 
> 
> 360
> 
> 
> 360
> 
> 
>  	 */
> 
> 
> 
> 
> 
> 361
> 
> 
> 361
> 
> 
>  
> 
> 
> 
> 
> 
> 362
> 
> 
>  
> 
> 
> -	/* set the unique serial number and timestamp */
> 
> 
> 
> 
> 
> 363
> 
> 
>  
> 
> 
> -	assign_serial(msg);
> 
> 
> 
> 
> 
> 364
> 
> 
>  
> 
> 
> -	store_message(msg);
> 
> 
> 
> 
> 
> 365
> 
> 
>  
> 
> 
> -
> 
> 
> 
> 
> 
> 366
> 
> 
> 362
> 
> 
>  	/* load sender */
> 
> 
> 
> 
> 
> 367
> 
> 
> 363
> 
> 
>  	struct user from;
> 
> 
> 
> 
> 
> 368
> 
> 
> 364
> 
> 
>  	fetch_user(&from, conn->user);
> 
> 
> 
> 
> ...
> ...
> @@ -374,12 +370,8 @@ void process_msg(ipc_connection_t *conn,
> ipc_message_t *msg)
> 
> 
> 
> 374
> 
> 
> 370
> 
> 
>  		const char * exclude = json_getstring(j, "exclude");
> 
> 
> 
> 
> 
> 375
> 
> 
> 371
> 
> 
>  		msg_attach_to_channel(msg, msg->head.dst, exclude);
> 
> 
> 
> 
> 
> 376
> 
> 
> 372
> 
> 
>  		json_decref(j);
> 
> 
> 
> 
> 
> 377
> 
> 
>  
> 
> 
> -		ipcmsg_destroy(msg);
> 
> 
> 
> 
> 
> 378
> 
> 
>  
> 
> 
> -		return;
> 
> 
> 
> 
> 
> 379
> 
> 
>  
> 
> 
> -	}
> 
> 
> 
> 
> 
> 380
> 
> 
>  
> 
> 
> -
> 
> 
> 
> 
> 
> 381
> 
> 
>  
> 
> 
> -	/* message is for a specific username */
> 
> 
> 
> 
> 
> 382
> 
> 
>  
> 
> 
> -	if (msg->head.type == IPC_SAYTOUSER) {
> 
> 
> 
> 
> 
>  
> 
> 
> 373
> 
> 
> +	} else if (msg->head.type == IPC_SAYTOUSER) {
> 
> 
> 
> 
> 
>  
> 
> 
> 374
> 
> 
> +		/* message is for a specific username */
> 
> 
> 
> 
> 
> 383
> 
> 
> 375
> 
> 
>  		msg_apply_gag(&from, msg, "text");
> 
> 
> 
> 
> 
> 384
> 
> 
> 376
> 
> 
>  		/* eventually this should be a server maintained
> list */
> 
> 
> 
> 
> 
> 385
> 
> 
> 377
> 
> 
>  		json_t * j = json_init(msg);
> 
> 
> 
> 
> ...
> ...
> @@ -388,15 +380,9 @@ void process_msg(ipc_connection_t *conn,
> ipc_message_t *msg)
> 
> 
> 
> 388
> 
> 
> 380
> 
> 
>  			send_error(conn, msg, "User '%s' not found",
> target);
> 
> 
> 
> 
> 
> 389
> 
> 
> 381
> 
> 
>  		}
> 
> 
> 
> 
> 
> 390
> 
> 
> 382
> 
> 
>  		json_decref(j);
> 
> 
> 
> 
> 
> 391
> 
> 
>  
> 
> 
> -		ipcmsg_destroy(msg);
> 
> 
> 
> 
> 
> 392
> 
> 
>  
> 
> 
> -		return;
> 
> 
> 
> 
> 
> 393
> 
> 
>  
> 
> 
> -
> 
> 
> 
> 
> 
> 394
> 
> 
>  
> 
> 
> -	}
> 
> 
> 
> 
> 
> 395
> 
> 
>  
> 
> 
> -
> 
> 
> 
> 
> 
> 396
> 
> 
>  
> 
> 
> -	/* send message to everyone (unless this room is soundproof)
> */
> 
> 
> 
> 
> 
> 397
> 
> 
>  
> 
> 
> -	if (msg->head.type == IPC_SAYTOALL) {
> 
> 
> 
> 
> 
>  
> 
> 
> 383
> 
> 
> +	} else if (msg->head.type == IPC_SAYTOALL) {
> 
> 
> 
> 
> 
>  
> 
> 
> 384
> 
> 
> +		/* send message to everyone (unless this room is
> soundproof) */
> 
> 
> 
> 
> 
> 398
> 
> 
> 385
> 
> 
>  		msg_apply_gag(&from, msg, "text");
> 
> 
> 
> 
> 
> 399
> 
> 
>  
> 
> 
> -
> 
> 
> 
> 
> 
> 400
> 
> 
> 386
> 
> 
>  		/* load the senders room to see if its soundproof */
> 
> 
> 
> 
> 
> 401
> 
> 
> 387
> 
> 
>  		struct room room;
> 
> 
> 
> 
> 
> 402
> 
> 
> 388
> 
> 
>  		RoomInit(&room);
> 
> 
> 
> 
> ...
> ...
> @@ -410,42 +396,29 @@ void process_msg(ipc_connection_t *conn,
> ipc_message_t *msg)
> 
> 
> 
> 410
> 
> 
> 396
> 
> 
>  			msg->head.type = IPC_SAYTOROOM;
> 
> 
> 
> 
> 
> 411
> 
> 
> 397
> 
> 
>  			msg->head.dst = from.record.room;
> 
> 
> 
> 
> 
> 412
> 
> 
> 398
> 
> 
>  			msg_attach_to_channel(msg, room.num, NULL);
> 
> 
> 
> 
> 
> 413
> 
> 
>  
> 
> 
> -			printf("Shout in soundproof room (%d) change
> to SAYTORROM %d\n",
> 
> 
> 
> 
> 
>  
> 
> 
> 399
> 
> 
> +			printf("Shout in soundproof room (%d) change
> to SAYTOROOM %d\n",
> 
> 
> 
> 
> 
> 414
> 
> 
> 400
> 
> 
>  			       room.sproof, from.record.room);
> 
> 
> 
> 
> 
> 415
> 
> 
> 401
> 
> 
>  		} else {
> 
> 
> 
> 
> 
> 416
> 
> 
> 402
> 
> 
>  			msg_attach_to_all(msg);
> 
> 
> 
> 
> 
> 417
> 
> 
> 403
> 
> 
>  		}
> 
> 
> 
> 
> 
> 418
> 
> 
>  
> 
> 
> -
> 
> 
> 
> 
> 
> 419
> 
> 
> 404
> 
> 
>  		RoomDestroy(&room);
> 
> 
> 
> 
> 
> 420
> 
> 
>  
> 
> 
> -		ipcmsg_destroy(msg);
> 
> 
> 
> 
> 
> 421
> 
> 
>  
> 
> 
> -		return;
> 
> 
> 
> 
> 
> 422
> 
> 
>  
> 
> 
> -	}
> 
> 
> 
> 
> 
> 423
> 
> 
>  
> 
> 
> -
> 
> 
> 
> 
> 
> 424
> 
> 
>  
> 
> 
> -	if (msg->head.type == IPC_EVENT) {
> 
> 
> 
> 
> 
>  
> 
> 
> 405
> 
> 
> +	} else if (msg->head.type == IPC_EVENT) {
> 
> 
> 
> 
> 
> 425
> 
> 
> 406
> 
> 
>  		printf("Event message\n");
> 
> 
> 
> 
> 
> 426
> 
> 
> 407
> 
> 
>  		msg_attach_to_all(msg);
> 
> 
> 
> 
> 
> 427
> 
> 
>  
> 
> 
> -		ipcmsg_destroy(msg);
> 
> 
> 
> 
> 
> 428
> 
> 
>  
> 
> 
> -		return;
> 
> 
> 
> 
> 
> 429
> 
> 
>  
> 
> 
> -	}
> 
> 
> 
> 
> 
> 430
> 
> 
>  
> 
> 
> -
> 
> 
> 
> 
> 
> 431
> 
> 
>  
> 
> 
> -	if (msg->head.type == IPC_WIZ) {
> 
> 
> 
> 
> 
>  
> 
> 
> 408
> 
> 
> +	} else if (msg->head.type == IPC_WIZ) {
> 
> 
> 
> 
> 
> 432
> 
> 
> 409
> 
> 
>  		printf("Wiz message\n");
> 
> 
> 
> 
> 
> 433
> 
> 
> 410
> 
> 
>  		msg_attach_to_perm(msg, PERM_WIZCHAT);
> 
> 
> 
> 
> 
> 434
> 
> 
>  
> 
> 
> -		ipcmsg_destroy(msg);
> 
> 
> 
> 
> 
> 435
> 
> 
>  
> 
> 
> -		return;
> 
> 
> 
> 
> 
> 436
> 
> 
>  
> 
> 
> -	}
> 
> 
> 
> 
> 
> 437
> 
> 
>  
> 
> 
> -
> 
> 
> 
> 
> 
> 438
> 
> 
>  
> 
> 
> -	/* it was a broadcast message */
> 
> 
> 
> 
> 
> 439
> 
> 
>  
> 
> 
> -	if (msg->head.dst == SYSTEM_USER) {
> 
> 
> 
> 
> 
>  
> 
> 
> 411
> 
> 
> +	} else if (msg->head.dst == SYSTEM_USER) {
> 
> 
> 
> 
> 
>  
> 
> 
> 412
> 
> 
> +		/* it was a broadcast message */
> 
> 
> 
> 
> 
> 440
> 
> 
> 413
> 
> 
>  		printf("Broadcast message to system user %s\n",
> ipc_nametype(msg->head.type));
> 
> 
> 
> 
> 
> 441
> 
> 
> 414
> 
> 
>  		msg_attach_to_all(msg);
> 
> 
> 
> 
> 
> 442
> 
> 
>  
> 
> 
> -		ipcmsg_destroy(msg);
> 
> 
> 
> 
> 
> 443
> 
> 
>  
> 
> 
> -		return;
> 
> 
> 
> 
> 
>  
> 
> 
> 415
> 
> 
> +	} else {
> 
> 
> 
> 
> 
>  
> 
> 
> 416
> 
> 
> +		/* otherwise redistribute this message to intended
> target */
> 
> 
> 
> 
> 
>  
> 
> 
> 417
> 
> 
> +		printf("Unhandled direct-to-user command %s\n",
> ipc_nametype(msg->head.type));
> 
> 
> 
> 
> 
>  
> 
> 
> 418
> 
> 
> +		msg_attach_to_userid(msg, msg->head.dst);
> 
> 
> 
> 
> 
> 444
> 
> 
> 419
> 
> 
>  	}
> 
> 
> 
> 
> 
> 445
> 
> 
>  
> 
> 
> -
> 
> 
> 
> 
> 
> 446
> 
> 
>  
> 
> 
> -	/* otherwise redistribute this message to intended target */
> 
> 
> 
> 
> 
> 447
> 
> 
>  
> 
> 
> -	printf("Unhandled direct-to-user command %s\n",
> ipc_nametype(msg->head.type));
> 
> 
> 
> 
> 
> 448
> 
> 
>  
> 
> 
> -	msg_attach_to_userid(msg, msg->head.dst);
> 
> 
> 
> 
> 
>  
> 
> 
> 420
> 
> 
> +	assign_serial(msg);
> 
> 
> 
> 
> 
>  
> 
> 
> 421
> 
> 
> +	store_message(msg);
> 
> 
> 
> 
> 
> 449
> 
> 
> 422
> 
> 
>  	ipcmsg_destroy(msg);
> 
> 
> 
> 
> 
> 450
> 
> 
> 423
> 
> 
>  }
> 
> 
> 
> 
> 
> 451
> 
> 
> 424
> 
> 
>  
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>> 
> 
> View it on GitLab.
> 
> 
> You're receiving this email because of your account on
> projects.sucs.org.
> If you'd like to receive fewer emails, you can
> adjust your notification settings.
> {"@context":"http://schema.org","@type":"EmailMessage","action":{"@ty
> pe":"ViewAction","name":"View Commit","url":"https://projects.sucs.or
> g/arthur/mw/commit/5e203b86272e2a2ce8ce831adad3ce0ecf7effa3"}}
> 
> 
> 
> 
> 
> _______________________________________________
> Milliways Development mailing list - mw-devel at lists.sucs.org - http:/
> /lists.sucs.org/mailman/listinfo/mw-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20171115/d1877df4/attachment-0001.html>


More information about the mw-devel mailing list