Fix update_port() so that it's done within the transaction

Fixes bug 1185152

Change-Id: I192991650a3562c73af550ec2288d1285412825c